From 3e9d40c2e0d49fd4b8abfd5d801e8f085d14748d Mon Sep 17 00:00:00 2001 From: Rob Chekaluk Date: Mon, 30 Dec 2013 08:44:55 -0500 Subject: [PATCH] Starting sidekiq via Capistrano requires a tty and nohup. --- examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb b/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb index cfd6ffb8..c20cde55 100644 --- a/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb +++ b/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb @@ -159,7 +159,8 @@ if [ -d $APP_ROOT ]; then fi fi if [ ! -f $PID_FILE ]; then - sudo -u $USER -H -i sh -c "cd $APP_ROOT; $COMMAND" >> $LOG_FILE 2>&1 & + # http://maymay.net/blog/2010/03/17/how-to-work-around-sorry-you-must-have-a-tty-to-run-sudo-without-sacrificing-security/ + nohup su - --session-command="cd $APP_ROOT; $COMMAND" $USER >> $LOG_FILE 2>&1 & RESULT=$? logger -t "monit-sidekiq[$$]" "Started with pid $! and exit $RESULT" echo $! > $PID_FILE