Skip to content

Commit

Permalink
Merge pull request sidekiq#2046 from sorentwo/upstart-logging
Browse files Browse the repository at this point in the history
Use a named pipe for logging in upstart example
  • Loading branch information
mperham committed Nov 11, 2014
2 parents 64bee3b + b40def9 commit 76f8d7e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
25 changes: 10 additions & 15 deletions examples/upstart/manage-many/sidekiq.conf
Expand Up @@ -21,8 +21,9 @@ description "Sidekiq Background Worker"
stop on (stopping sidekiq-manager or runlevel [06])

# change apps to match your deployment user if you want to use this as a less privileged user (recommended!)
# setuid apps
# setgid apps
# setuid deploy
# setgid deploy
# env HOME=/home/apps

respawn
respawn limit 3 30
Expand All @@ -35,12 +36,7 @@ instance ${app}-${index}
script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv
exec /bin/bash <<EOT
# uncomment to use syslog for logging
# exec &> /dev/kmsg

export HOME=/home/apps

exec /bin/bash <<'EOT'
# Pick your poison :) Or none if you're using a system wide installed Ruby.
# rbenv
# source /home/apps/.bash_profile
Expand All @@ -54,6 +50,8 @@ exec /bin/bash <<EOT

logger -t sidekiq "Starting process: $app-$index"

# Logs out to /var/log/upstart/sidekiq.log by default

cd $app
exec bundle exec sidekiq -i ${index} -e production -P tmp/pids/${app}-${index}.pid
EOT
Expand All @@ -62,12 +60,7 @@ end script
pre-stop script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv
exec /bin/bash <<EOT
# uncomment to use syslog for logging
# exec &> /dev/kmsg

export HOME=/home/apps

exec /bin/bash <<'EOT'
# Pick your poison :) Or none if you're using a system wide installed Ruby.
# rbenv
# source /home/apps/.bash_profile
Expand All @@ -81,7 +74,9 @@ exec /bin/bash <<EOT

logger -t sidekiq "Stopping process: $app-$index"

# Logs out to /var/log/upstart/sidekiq.log by default

cd $app
exec bundle exec sidekiqctl stop tmp/pids/${app}-${index}.pid
exec bundle exec sidekiqctl stop tmp/pids/${app}-${index}.pid 2> /dev/null
EOT
end script
35 changes: 19 additions & 16 deletions examples/upstart/manage-one/sidekiq.conf
Expand Up @@ -21,14 +21,15 @@ description "Sidekiq Background Worker"
stop on (stopping workers or runlevel [06])

# change to match your deployment user
setuid deploy
setgid deploy
env HOME=/home/deploy
# setuid deploy
# setgid deploy
# env HOME=/home/deploy

respawn
respawn limit 3 30

# TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as normal exit codes, it just respawns.
# TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as
# normal exit codes, it just respawns.
normal exit 0 TERM

instance $index
Expand All @@ -37,18 +38,20 @@ script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv
exec /bin/bash <<'EOT'
# use syslog for logging
exec &> /dev/kmsg

# pull in system rbenv
source /etc/profile.d/rbenv.sh
# or
# pull in user installed rbenv
# export PATH="$HOME/.rbenv/bin:$PATH"
# eval "$(rbenv init -)"
# export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"

cd /opt/theclymb/current
# Pick your poison :) Or none if you're using a system wide installed Ruby.
# rbenv
# source /home/apps/.bash_profile
# OR
# source /home/apps/.profile
# OR system:
# source /etc/profile.d/rbenv.sh
#
# rvm
# source /home/apps/.rvm/scripts/rvm

# Logs out to /var/log/upstart/sidekiq.log by default

cd /var/www/app
exec bin/sidekiq -i ${index} -e production
EOT
end script

0 comments on commit 76f8d7e

Please sign in to comment.