summaryrefslogtreecommitdiff
path: root/init-script
blob: 6dba4f040c09f4ef779bf8b0faced1925b61b6d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 $?
}