Created
May 5, 2014 08:24
-
-
Save yauh/57814053f146114425cb to your computer and use it in GitHub Desktop.
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 | |
# | |
# description: Script to start a meteor application through forever | |
# processname: forever/coffeescript/node | |
# pidfile: /var/run/forever-initd-meteor.pid | |
# logfile: /var/run/forever-initd-meteor.log | |
# | |
# Based on a script posted by | |
# https://github.com/hectorcorrea/hectorcorrea.com/blob/master/etc/forever-initd-hectorcorrea.sh | |
# | |
### BEGIN INIT INFO | |
# Provides: meteor | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Should-Start: $portmap | |
# Should-Stop: $portmap | |
# X-Start-Before: nis | |
# X-Stop-After: nis | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# X-Interactive: true | |
# Short-Description: MeteorJobs Tweetbot | |
# Description: This file should be used to construct scripts to be | |
# placed in /etc/init.d. | |
### END INIT INFO | |
# Source function library. | |
. /lib/lsb/init-functions | |
pidfile=/var/run/forever-initd-meteor.pid | |
logFile=/var/run/forever-initd-meteor.log | |
errFile=/var/run/forever-initd-meteor.err | |
outFile=/var/run/forever-initd-meteor.out | |
sourceDir=/var/www/meteor/myapp | |
scriptId=$sourceDir/main.js | |
start() { | |
echo "Starting $scriptId" | |
# This is found in the library referenced at the top of the script | |
start_daemon | |
# Notice that we change the PATH because on reboot | |
# the PATH does not include the path to node. | |
cd $sourceDir | |
PATH=/usr/local/bin:$PATH | |
PORT=3921 MONGO_URL=mongodb://user:password@localhost:27017/meteor ROOT_URL=http://example.org MAIL_URL=smtp://localhost:25 forever start --pidFile $pidfile -l $logFile -o $outFile -e $errFile -a -d --sourceDir $sourceDir/ main.js | |
RETVAL=$? | |
} | |
restart() { | |
echo -n "Restarting $scriptId" | |
/usr/local/bin/forever restart $scriptId | |
RETVAL=$? | |
} | |
stop() { | |
echo -n "Shutting down $scriptId" | |
/usr/local/bin/forever stop $scriptId | |
RETVAL=$? | |
} | |
status() { | |
echo -n "Status $scriptId" | |
/usr/local/bin/forever list | |
RETVAL=$? | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Usage: {start|stop|status|restart}" | |
exit 1 | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment