简体   繁体   中英

Unicorn & nginx error

vagrant@lucid32:/vagrant$ bundle exec unicorn_rails -c config/unicorn.rb -D -d
{:unicorn_options=>{:listeners=>[], :config_file=>"config/unicorn.rb"},
 :app=>
  #<Proc:0xa1a6ef4@/home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/bin/unicorn_rails:135 (lambda)>,
 :daemonize=>true}
Exception `Errno::EEXIST' at /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:247 - File exists - tmp/cache
Exception `Errno::EEXIST' at /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:247 - File exists - tmp/pids
Exception `Errno::EEXIST' at /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:247 - File exists - tmp/sessions
Exception `Errno::EEXIST' at /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:247 - File exists - tmp/sockets
Exception `EOFError' at /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/launcher.rb:46 - end of file reached
master failed to start, check stderr log for details

Unfortunately I have no idea how to check the stderr log and culd not find any relevant information.

Here's the config file:

working_directory "/vagrant"
pid "/vagrant/tmp/pids/unicorn.pid"
stderr_path "/vagrant/log/unicorn.log"
stdout_path "/vagrant/log/unicorn.log"

listen "/tmp/unicorn.todo.sock"
worker_processes 2
timeout 30

And here is the nginx.conf file

upstream unicorn {
  server unix:/tmp/unicorn.todo.sock fail_timeout=0;
}


server {
  listen 80 default;
  # server_name example.com;
  root /vagrant/public;
  try_files $uri/index.html $uri @unicorn;
  location @unicorn {
      proxy_pass  http://unicorn;
  }

  error_page 500 502 503 504 /500.html;
}

Now the thing is that the /tmp directory is not being created. So i created it and i get the same error, then i deleted it and i get the same error. and now i am stuck in an infinite loop.

I would appreciate any help about ho to make this work or at least how to read the error log.

EDIT: i was able to find the stderr file:

/home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `rename': Text file busy - (/vagrant/tmp/pids/0.2278780536507904.2128, /vagrant/tmp/pids/unicorn.pid) (Errno::ETXTBSY)
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `pid='
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:137:in `start'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `load'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `<main>'
/home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `rename': Text file busy - (/vagrant/tmp/pids/0.8313958669768073.2187, /vagrant/tmp/pids/unicorn.pid) (Errno::ETXTBSY)
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `pid='
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:137:in `start'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `load'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `<main>'
/home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `rename': Text file busy - (/vagrant/tmp/pids/0.9130633695817217.2190, /vagrant/tmp/pids/unicorn.pid) (Errno::ETXTBSY)
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `pid='
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:137:in `start'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `load'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `<main>'
Exception `Errno::ENOENT' at /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:683 - No such file or directory - /vagrant/tmp/pids/unicorn.pid
Exception `Errno::ETXTBSY' at /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207 - Text file busy - (/vagrant/tmp/pids/0.59100125503182.2237, /vagrant/tmp/pids/unicorn.pid)
/home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `rename': Text file busy - (/vagrant/tmp/pids/0.59100125503182.2237, /vagrant/tmp/pids/unicorn.pid) (Errno::ETXTBSY)
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `pid='
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:137:in `start'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `load'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `<main>'
/home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `rename': Text file busy - (/vagrant/tmp/pids/0.4331021743697998.2271, /vagrant/tmp/pids/unicorn.pid) (Errno::ETXTBSY)
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:207:in `pid='
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:137:in `start'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `load'
        from /home/vagrant/.rbenv/versions/1.9.3-p392/bin/unicorn:23:in `<main>'
Exception `Errno::ENOENT' at /home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:683 - No such file or directory - /vagrant/tmp/pids/unicorn.pid

Unicorn process is running in background(-d), type below command on teminal

ps aux | grep unicorn

and kill running unicorn process then start unicorn again.

I had this same problem (the Text file busy error), also running from a Vagrant VM. @destiel's comment helped me solve the problem: Apparently this is caused by running rails and unicorn from the Vagrant shared folder. After copying to the virtual drive, it worked fine. I'm running on a Windows 8 host, in case that matters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM