Created
December 17, 2013 01:15
-
-
Save ssut/7998286 to your computer and use it in GitHub Desktop.
Starts and stops "sidekiq" message processor for padrino application.
Requirement: rbenv, padrino, sidekiq and https://gist.github.com/passcod/3754086 /etc/init.d/sidekiq
This file contains 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/sh | |
### BEGIN INIT INFO | |
## END INIT INFO | |
# You will need to modify these.. | |
APP="app_name" | |
APP_DIR="/var/www/${APP}" | |
CONFIG_FILE="${APP_DIR}/config/sidekiq.yml" | |
REQUIRE="${APP_DIR}/config/workers.rb" | |
PID_FILE="${APP_DIR}/tmp/sidekiq.pid" | |
LOG_FILE="${APP_DIR}/log/sidekiq.log" | |
RUBY_DIR="/home/ssut/.rbenv/shims" | |
USER="www-data" | |
export RUBY_DIR | |
. /lib/lsb/init-functions | |
EXEC_CMD="${RUBY_DIR}/bundle" | |
EXEC_ARGS="exec sidekiq -C ${CONFIG_FILE} -r ${REQUIRE} -L ${LOG_FILE}" | |
case "$1" in | |
start) | |
echo -n "Starting sidekiq service: " | |
rm -f ${PID_FILE} | |
sudo start-stop-daemon --start --background --user ${USER} --make-pidfile --pidfile ${PID_FILE} -d ${APP_DIR} --exec "${EXEC_CMD}" -- $EXEC_ARGS | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ]; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
;; | |
stop) | |
echo -n "Shutting down sidekiq service: " | |
sudo start-stop-daemon --stop --pidfile ${PID_FILE} | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ]; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
;; | |
status) | |
ps -ef | grep 'sidekiq' | grep -v grep >> /dev/null | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ]; then | |
echo "SIDEKIQ service is running !" | |
else | |
echo "SIDEKIQ service is stopped ." | |
fi | |
;; | |
*) | |
echo "Usage: ${SCRIPTNAME} {start|stop|status}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment