title: Starting or restarting Unicorn with Capistrano 3.x
body: <p>I'm trying to start or restart Unicorn when I do <code>cap production deploy</code> with Capistrano 3.0.1.  I have some examples that I got working with Capistrano 2.x using something like: </p>
  
  <pre><code>namespace :unicorn do
    desc "Start unicorn for this application"
    task :start do
      run "cd #{current_path} &amp;&amp; bundle exec unicorn -c /etc/unicorn/myapp.conf.rb -D"
    end
  end
  </code></pre>
  
  <p>But when I try and use <code>run</code> in the <code>deploy.rb</code> for Capistrano 3.x I get an undefined method error.</p>
  
  <p>Here are a couple of the things I tried:</p>
  
  <pre><code># within the :deploy I created a task that I called after :finished
  namespace :deploy do
  ...
  
    task :unicorn do
      run "cd #{current_path} &amp;&amp; bundle exec unicorn -c /etc/unicorn/myapp.conf.rb -D"
    end
  
    after :finished, 'deploy:unicorn'
  
  end
  </code></pre>
  
  <p>I have also tried putting the run within the :restart task</p>
  
  <pre><code>namespace :deploy do
    desc 'Restart application'
    task :restart do
  
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # execute :touch, release_path.join('tmp/restart.txt')
      execute :run, "cd #{current_path} &amp;&amp; bundle exec unicorn -c /etc/unicorn/deployrails.conf.rb -D"
    end
  end    
  </code></pre>
  
  <p>If I use just <code>run "cd ... " then I'll get a</code>wrong number of arguments (1 for 0)` in the local shell.</p>
  
  <p>I can start the unicorn process with <code>unicorn -c /etc/unicorn/deployrails.conf.rb -D</code> from my ssh'd VM shell. </p>
  
  <p>I can kill the master Unicorn process from the VM shell using kill USR2, but even though the process is killed I get an error. I can then start the process again using <code>unicorn -c ...</code></p>
  
  <pre><code>$ kill USR2 58798
  bash: kill: USR2: arguments must be process or job IDs
  </code></pre>
  
  <p>I'm very new to Ruby, Rails and Deployment in general. I have a VirtualBox setup with Ubuntu, Nginx, RVM and Unicorn, I'm pretty excited so far, but this one is really messing with me, any advice or insight is appreciated.</p>