title: How to automatically restart delayed_job when deploying a rails project on Amazon Elastic Beanstalk?
body: <p>I'm hosting a rails project on <a href="http://aws.amazon.com/en/elasticbeanstalk/" rel="noreferrer">Amazon Elastic Beanstalk</a> and I try to configure a <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands" rel="noreferrer">container command</a> to automatically restart my <a href="https://github.com/collectiveidea/delayed_job" rel="noreferrer">delayed_job</a> worker on the server after each deployment.</p>
  
  <p>I tried with this one : </p>
  
  <pre><code>container_commands:
    restartdelayedjob:
      command: "RAILS_ENV=production script/delayed_job --pid-dir=/home/ec2-user/pids start"
      cwd: /var/app/current
  </code></pre>
  
  <p>But, it seems that the pushed version is deployed after the restarting of the worker so the jobs failed to be processed by the worker.</p>
  
  <p>When I connect on my instance by ssh, kill the worker process and restart a new one from the deployed version folder, everything works fine. </p>
  
  <p>Do you have any ideas of how I can handle this?</p>
  
  <p>Thanks</p>