forked from MemedDev/mysql-to-google-bigquery
-
Notifications
You must be signed in to change notification settings - Fork 1
/
init-startup-script
50 lines (45 loc) · 951 Bytes
/
init-startup-script
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
#!/bin/sh
#
# chkconfig: 2345 50 50
# description: The daemon for uploading data from mysql to GBQ
# source function library
. /etc/rc.d/init.d/functions
PROG='vendor/bin/runner'
WORKDIR='/opt/bq-uploader'
LOGFILE='/var/log/bq-uploader.log'
PIDFILE='/var/run/bq-uploader.pid'
BASE='runner'
USER='root'
START="${PROG} 2>&1 >> ${LOGFILE} &"
case "$1" in
start)
echo -n $"Starting $BASE: "
cd ${WORKDIR}
daemon --user $USER --check $BASE $START
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASE
PID=`ps ax | grep 'vendor/bin/runner' | grep -v grep | awk {'print $1'}`
echo ${PID} > ${PIDFILE}
echo
;;
stop)
echo -n $"Shutting down $BASE: "
killproc -p ${PIDFILE}
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASE
echo
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
status -p ${PIDFILE}
;;
*)
echo "Usage: $0 {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0