title: daemonizing sidekiq with upstart script - is not working
body: <p>I'm trying to daemonize sidekiq using two upstart scripts following <a href="https://github.com/mperham/sidekiq/tree/master/examples/upstart/manage-one" rel="nofollow">this</a> example.
  Basically the workers service starts a fixed number of sidekiq services.</p>
  
  <p>The problem is that the sidekiq script fails at the line of code where I am starting sidekiq. I've tried to run the command directly in bash and it works fine.</p>
  
  <p>I tried all different commented lines and none works.</p>
  
  <p>So my question is what am I doing wrong? Where can I see the error messages?</p>
  
  <p>This is my modified sidekiq script:</p>
  
  <pre><code># /etc/init/sidekiq.conf - Sidekiq config
  
  # This example config should work with Ubuntu 12.04+.  It
  # allows you to manage multiple Sidekiq instances with
  # Upstart, Ubuntu's native service management tool.
  #
  # See workers.conf for how to manage all Sidekiq instances at once.
  #
  # Save this config as /etc/init/sidekiq.conf then mange sidekiq with:
  #   sudo start sidekiq index=0
  #   sudo stop sidekiq index=0
  #   sudo status sidekiq index=0
  #
  # or use the service command:
  #   sudo service sidekiq {start,stop,restart,status}
  #
  
  description "Sidekiq Background Worker"
  
  respawn
  respawn limit 15 5
  
  # no "start on", we don't want to automatically start
  stop on (stopping workers or runlevel [06])
  
  # TERM and USR1 are sent by sidekiqctl when stopping sidekiq.  Without declaring these    as normal exit codes, it just respawns.
  normal exit 0 TERM USR1
  
  instance $index
  
  script
  exec /bin/bash &lt;&lt;EOT
    # use syslog for logging
    # exec &amp;&gt; /dev/kmsg
  
    # pull in system rbenv
    # export HOME=/home/deploy
    # source /etc/profile.d/rbenv.sh
  
    cd /home/rails
    touch /root/sidekick_has_started
    sidekiq -i ${index} -e production
    # exec sidekiq -i ${index} -e production
    # exec /usr/local/rvm/gems/ruby-2.0.0-p353/gems/sidekiq-3.1.3/bin/sidekiq -i ${index} -e production
    touch /root/sidekick_has_started_2
  EOT
  end script
  </code></pre>