From 7932d455f193e66550f139840e8921098cbfec6f Mon Sep 17 00:00:00 2001 From: Rob Chekaluk Date: Thu, 26 Dec 2013 13:12:25 -0500 Subject: [PATCH] Use sudo -i switch (simulate initial login) incorporates RVM environment when using RVM. Also chdir into the proper directory since this switch implies using the user home directory. --- examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb b/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb index 522c28fb..f4b4984e 100644 --- a/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb +++ b/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb @@ -158,7 +158,7 @@ if [ -d $APP_ROOT ]; then fi fi if [ ! -f $PID_FILE ]; then - sudo -u $USER -H $COMMAND >> $LOG_FILE 2>&1 & + sudo -u $USER -H -i sh -c "cd $APP_ROOT; $COMMAND" >> $LOG_FILE 2>&1 & RESULT=$? logger -t "monit-sidekiq[$$]" "Started with pid $! and exit $RESULT" echo $! > $PID_FILE