Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to figure out why my process doesn't work if started via a script, but works fine if started by hand.

Here's the details:

script is a resque worker start script. The script location is /etc/monit/conf.d/start_resque.sh. Permissions are 755 and owned by ubuntu:ubuntu

When I run the script, the log output gets a pid and it says "starting worker ip-xx-xxx-xxx-xx:26732 (or whatever the pid is)", however when I ps aux | grep 26732, nothing is shown as running. When I run the same exact command by hand in my rails project directory, the same "starting worker" output is displayed, and the process is actually started and continues to run. One thing to note, additional output is displayed if started by hand: "nohup: ignoring input"

Another question someone might be able to help with, is why does BACKGROUND=yes not actually daemonize my worker...thus I'm resorting to nohup, which seems to work fine.

Here's my script (the command I run by hand is after the cd):

#!/bin/bash
echo "starting worker.."
workercount="$(ps aux | grep -c resque)"
currentdir="/var/www/apps/myapp/current"
logdir=$currentdir/log/resque_worker.log
pidfile=$currentdir/tmp/pids/resque_worker_$workercount.pid
cd $currentdir
nohup bundle exec rake environment resque:work RAILS_ENV=production QUEUE='*' VERBOSE=1 PIDFILE=$pidfile >> $logdir 2>&1 &
echo "started worker $workercount! view log at $logdir. view pidfile at $pidfile"

Additional notes: on Ubuntu 12.04 and am connected via ssh while running both the script and the manual command.

share|improve this question
    
Try running pstree to see if the child ( your background process ) was adopted by init ;) –  Rany Albeg Wein Apr 22 '13 at 19:07
    
I don't think it has been, since I don't see it there. I do see redis-server, but no children attached to that process. –  Danny Apr 22 '13 at 22:49
add comment

1 Answer

Ok I switched to Sidekiq and it "just works". Lots of lost time mucking around with resque and deploying, but I gained some xp and almost leveled up in my sysadmin skill. Sidekiq seems a better option - it takes advantage of threads and has a great wiki, updated web interface, a pro option, and a really cool ninja icon on their homepage.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.