summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinit-script35
1 files changed, 35 insertions, 0 deletions
diff --git a/init-script b/init-script
new file mode 100755
index 0000000..6dba4f0
--- /dev/null
+++ b/init-script
@@ -0,0 +1,35 @@
+#!/sbin/openrc-run
+
+thisdir="$(dirname "$(readlink -f "$RC_SERVICE")")"
+export HOME="$thisdir"
+
+description="syntax highlighter service"
+: ${pidfile:=/run/color.pid}
+: ${instances:=2}
+: ${logbase:=/var/log/color}
+
+depend() {
+ use net
+}
+
+my_args=( --instances "$instances"
+ --output "${logbase}.out"
+ --error "${logbase}.err"
+ --pid "$pidfile" --silent )
+
+start() {
+ ebegin "Starting color"
+ "${thisdir}/node_modules/.bin/pm2" \
+ "${my_args[@]}" \
+ --name color \
+ start "${thisdir}/index.js"
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping color"
+ "${thisdir}/node_modules/.bin/pm2" \
+ "${my_args[@]}" \
+ kill
+ eend $?
+}