使用capistrano部署时出错
DEBUG [aaaad896] Command: cd /home/dev/PROJECT-NAME/current && ( export RAILS_ENV="production" ; ~/.rvm/bin/rvm default do bundle exec unicorn -c /home/dev/PROJECT-NAME/current/config/unicorn.rb -E deployment -D )
DEBUG [aaaad896] master failed to start, check stderr log for details
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: master failed to start, check stderr log for details
其他日志。
Errno::EADDRINUSE: Address already in use - bind(2) for 0.0.0.0:8080
/home/dev/PROEJCT-NAME/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/socket_helper.rb:149:in `bind'
unicorn.rb文件:unicorn.rb
deploy.rb文件deploy.rb
default(nginx / site-enabled / default)文件:qazxsw poi
每次重新启动独角兽时我都会在capistrano中收到此错误。那么我该如何解决这个问题呢?
问题是您在端口8080中有另一个服务侦听,这就是您的日志所说的内容。如果你正在使用linux,你可以检查它使用default的服务。这将告诉您谁正在使用该端口。如果您可以终止服务,只需执行此操作,如果不能,只需更改配置文件上的端口即可。
要杀死已经运行的进程,您可以使用它来检查它们
lsof -i:8080
哪个会列出类似的东西
ps aux | grep unicorn
然后你可以用它们杀死它们
deployer 3807 2.8 9.3 369964 94996 ? Sl 12:51 0:03 unicorn master -D -c /home/deployer/apps/cb_app/current/config/unicorn.rb -E staging
deployer 3816 0.0 8.5 369964 87040 ? Sl 12:51 0:00 unicorn worker[0] -D -c /home/deployer/apps/cb_app/current/config/unicorn.rb -E staging
deployer 3818 0.0 8.5 369964 87200 ? Sl 12:51 0:00 unicorn worker[1] -D -c /home/deployer/apps/cb_app/current/config/unicorn.rb -E staging
现在再次尝试部署并查看主服务器是否启动。
有时它只是关于权限,因为独角兽重启它需要写入日志。检查/ log的文件夹权限,并使其对所有人都可写。