title: Unicorn unable to write pid file
body: <p>I am using deploying a Ruby on Rails app to a Linode VPS using Capistrano. I am using Unicorn as the application server and Nginx as the proxy. My problem is that I am not able to start Unicorn because of an apparent permissions issue, but I'm having a hard time tracking it down.</p>
  
  <p>Unicorn is started using this Capistrano task:</p>
  
  <pre class="lang-ruby prettyprint-override"><code>task :start, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do
      run &lt;&lt;-CMD
        cd #{current_path} &amp;&amp; #{unicorn_bin} -c #{unicorn_config} -E #{rails_env} -D
      CMD
  end
  </code></pre>
  
  <p>I get back and ArgumentError indicating that the path to the pid file is not writeable.</p>
  
  <pre class="lang-shell prettyprint-override"><code>cap unicorn:start                                                                           master [d4447d3] modified
    * executing `unicorn:start'
    * executing "cd /home/deploy/apps/gogy/current &amp;&amp; /home/deploy/apps/gogy/current/bin/unicorn -c /home/deploy/apps/gogy/shared/config/unicorn.rb -E production -D"
      servers: ["66.228.52.4"]
      [66.228.52.4] executing command
   ** [out :: 66.228.52.4] /home/deploy/apps/gogy/shared/bundle/ruby/1.8/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:88:in `reload':
   ** [out :: 66.228.52.4] directory for pid=/home/deploy/apps/shared/pids/unicorn.pid not writable (ArgumentError)
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/shared/bundle/ruby/1.8/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:84:in `each'
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/shared/bundle/ruby/1.8/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:84:in `reload'
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/shared/bundle/ruby/1.8/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:65:in `initialize'
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/shared/bundle/ruby/1.8/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:102:in `new'
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/shared/bundle/ruby/1.8/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:102:in `initialize'
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/shared/bundle/ruby/1.8/gems/unicorn-4.1.1/bin/unicorn:121:in `new'
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/shared/bundle/ruby/1.8/gems/unicorn-4.1.1/bin/unicorn:121
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/current/bin/unicorn:16:in `load'
   ** [out :: 66.228.52.4] from /home/deploy/apps/gogy/current/bin/unicorn:16
   ** [out :: 66.228.52.4] master failed to start, check stderr log for details
      command finished in 1032ms
  failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'default' -c 'cd /home/deploy/apps/gogy/current &amp;&amp; /home/deploy/apps/gogy/current/bin/unicorn -c /home/deploy/apps/gogy/shared/config/unicorn.rb -E production -D'" on 66.228.52.4
  </code></pre>
  
  <p>Finally, here is the relevant sections of my Unicorn configuration file (unicorn.rb)</p>
  
  <pre class="lang-ruby prettyprint-override"><code># Ensure that we're running in the production environment
  rails_env = ENV['RAILS_ENV'] || 'production'
  
  # User to run under
  user 'deploy', 'deploy'
  
  # We will spawn off two worker processes and one master process
  worker_processes 2
  
  # set the default working directory
  working_directory "/home/deploy/apps/gogy/current"
  
  # This loads the application in the master process before forking
  # worker processes
  # Read more about it here:
  # http://unicorn.bogomips.org/Unicorn/Configurator.html
  preload_app true
  
  timeout 30
  
  # This is where we specify the socket.
  # We will point the upstream Nginx module to this socket later on
  listen "/home/deploy/apps/shared/sockets/unicorn.sock", :backlog =&gt; 64
  
  pid "/home/deploy/apps/shared/pids/unicorn.pid"
  
  # Set the path of the log files 
  stderr_path "/home/deploy/apps/gogy/current/log/unicorn.stderr.log"
  stdout_path "/home/deploy/apps/gogy/current/log/unicorn.stdout.log"
  </code></pre>
  
  <p>I'm deploying with Capistrano under the 'deploy' user and group and that's what Unicorn should be run under also.</p>
  
  <p>Does anyone have any ideas why Unicorn can't write out the pid file? Any help would be greatly appreciated!!!</p>
  
  <ul>
  <li>Mike</li>
  </ul>