-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlatexcd
executable file
·70 lines (59 loc) · 1.39 KB
/
latexcd
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#
# Startup script for the latexcd Server
#
# chkconfig: – 50 50
# description: latexcd is a continuous compilation service for LaTeX files
# processname: latexcd
# pidfile: /opt/latexcd/latexcd.pid
# config: /opt/latexcd/latexcd.conf
# command: /opt/latexcd/latexcd/webhook_start
PREFIX=/opt/latexcd
CONFIG_FILE=$PREFIX/latexcd.conf
PID_FILE=$PREFIX/latexcd.pid
PULLANDBUILD_PATH=$PREFIX/latex_cd/pullandbuild.sh
SINATRA_PATH=$PREFIX/latex_cd/webhook.rb
CMD=$PREFIX/latex_cd/webhook_start
set -a
. $CONFIG_FILE
set +a
DAEMON="start-stop-daemon"
DAEMON_OPTS="-o --pidfile $PID_FILE --user $USER"
case "$1" in
start)
# Starts the latexcd deamon
echo "Starting latexcd"
export PULLANDBUILD_PATH SINATRA_PATH
$DAEMON --start $DAEMON_OPTS --background -m -g $GROUP -c $USER --exec $CMD
if [ $? -eq 0 ]; then
echo "Server running. Check $LOGFILE for status."
else
echo "Error starting webserver"
fi
;;
stop)
pid=$(cat $PID_FILE)
$DAEMON --stop $DAEMON_OPTS --retry=INT/5/TERM/2/KILL/1
if [ $? -ne 0 ]; then
pkill -P $pid
fi
;;
status)
if $DAEMON --status $DAEMON_OPTS ; then
echo "latexcd is running, PID $(cat $PID_FILE)"
else
echo "latexcd is not running"
fi
;;
restart)
## Stop the service regardless of whether it was
## running or not, start it again.
echo "Restarting latexcd"
$0 stop
$0 start
;;
*)
echo "Usage: latexcd (start|stop|restart|status)"
exit 1
;;
esac