Created
March 13, 2013 05:07
-
-
Save holysugar/5149528 to your computer and use it in GitHub Desktop.
/etc/init.d/growthforecast with mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # /etc/rc.d/init.d/growthforecast | |
| # | |
| # chkconfig: - 80 20 | |
| # description: growthforecast | |
| # processname: growthforecast | |
| # pidfile: /var/run/growthforecast/growthforecast.pid | |
| # | |
| ### BEGIN INIT INFO | |
| # Provides: growthforecast | |
| # Default-Stop: 0 1 6 | |
| # Required-Start: $local_fs | |
| # Required-Stop: $local_fs | |
| ### END INIT INFO | |
| # Source function library. | |
| . /etc/init.d/functions | |
| name="growthforecast" | |
| prog="growthforecast.pl" | |
| USER="fluentd" | |
| PERLVER=5.16.2 | |
| PROG_PATH=/home/${USER}/perl5/perlbrew/perls/perl-${PERLVER}/bin/growthforecast.pl | |
| LISTEN=127.0.0.1 | |
| LOG="/var/log/${name}/${name}.log" | |
| DAEMON_ARGS="--user ${USER}" | |
| PIDFILE=/var/run/${name}/${name}.pid | |
| PROG_ARGS="--with-mysql 'dbi:mysql:growthforecast;hostname=localhost' --host ${LISTEN} --front-proxy 127.0.0.1 --port 5125 >> $LOG 2>&1 & echo \$! > ${PIDFILE}" | |
| export MYSQL_USER=growthforecast | |
| export MYSQL_PASSWORD=XXXXXX | |
| start() { | |
| if [ -f /var/lock/subsys/$prog ];then | |
| echo "${prog} is runnig......" | |
| exit | |
| fi | |
| echo -n "Starting $name: " | |
| daemon $DAEMON_ARGS $PROG_PATH "$PROG_ARGS" | |
| RETVAL=$? | |
| echo | |
| [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog | |
| return $RETVAL | |
| } | |
| stop() { | |
| echo -n "Shutting down $name: " | |
| if [ -e "${PIDFILE}" ]; then | |
| killproc -p ${PIDFILE} || killproc $prog | |
| else | |
| killproc $prog | |
| fi | |
| RETVAL=$? | |
| echo | |
| [ $RETVAL -eq 0 ] && rm -f $PIDFILE && rm -f /var/lock/subsys/$prog | |
| return $RETVAL | |
| } | |
| restart() { | |
| stop | |
| start | |
| } | |
| case "$1" in | |
| start) | |
| start | |
| ;; | |
| stop) | |
| stop | |
| ;; | |
| restart) | |
| restart | |
| ;; | |
| reload) | |
| killproc $prog -HUP | |
| ;; | |
| condrestart) | |
| [ -f /var/lock/subsys/$prog ] && restart || : | |
| ;; | |
| status) | |
| status $prog | |
| ;; | |
| *) | |
| echo "Usage: $prog {start|stop|reload|restart|condrestart|status}" | |
| exit 1 | |
| ;; | |
| esac | |
| exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment