简体   繁体   English

无法在Ubuntu 16.04上运行Puma upstart脚本

[英]Cannot run Puma upstart script on Ubuntu 16.04

I'm trying to start my Ruby on Rails applications manually, but am running into an issue. 我正在尝试手动启动我的Ruby on Rails应用程序,但遇到了问题。

When running 'sudo start puma-manager' or 'sudo start puma app=/home//' I'm getting the following error: 'Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused'. 当运行'sudo start puma-manager'或'sudo start puma app = / home //'时,我收到以下错误:'无法连接到Upstart:无法连接到socket / com / ubuntu / upstart:连接被拒绝”。

I'm going through this tutorial: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04 , on Ubuntu 16.04 (no other surprises, other than using 16.04 I've followed this tutorial to the last detail). 我正在阅读本教程: https//www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04 ,在Ubuntu 16.04上(没有其他惊喜,除了使用16.04我已经按照本教程的最后细节)。 Is there a good way to get upstart to work? 是否有一个很好的方法让新手上班?

I just read that upstart isn't available on 16.04. 我刚才读到16.04没有新贵。 Is that true? 真的吗? I find it hard to believe that puma doesn't have a good workaround for this. 我发现很难相信美洲狮没有一个好的解决方法。 It seems too common. 这似乎太常见了。

Thanks for your help! 谢谢你的帮助!

I had the same problem and for a while this was a reason for me to not upgrade to Ubuntu 16, but we have to keep moving on with this changes. 我有同样的问题,有一段时间这是我没有升级到Ubuntu 16的原因,但我们必须继续这个变化。 Systemd can be scary, but once you start having experience setting up service scripts it can be easier than Upstart. Systemd可能很吓人,但是一旦你开始有设置服务脚本的经验,它可能比Upstart更容易。

  1. Create a file named puma.service in /etc/systemd/system/ similar to this one: 在/ etc / systemd / system /中创建一个名为puma.service的文件,类似于这个:

     [Unit] Description=Puma HTTP Server After=network.target [Service] Type=simple # Preferably configure a non-privileged user User=appuser # Specify the path to your puma application root WorkingDirectory=/home/deploy/appname # Helpful for debugging socket activation, etc. Environment=PUMA_DEBUG=1 # Setting secret_key_base for rails production environment. We can set other Environment variables the same way, for example PRODUCTION_DATABASE_PASSWORD Environment=SECRET_KEY_BASE=b7fbccc14d4018631dd739e8777a3bef95ee8b3c9d8d51f14f1e63e613b17b92d2f4e726ccbd0d388555991c9e90d3924b8aa0f89e43eff800774ba29 # The command to start Puma, use 'which puma' to get puma's bin path, specify your config/puma.rb file ExecStart=/usr/local/bin/puma -C /home/deploy/appname/config/puma.rb Restart=always [Install] WantedBy=multi-user.target 
  2. Run these commands to bring the systemd service up. 运行这些命令以启动systemd服务。

     systemctl daemon-reload systemctl enable puma.service systemctl start puma.service 

Your service will be up if you have done right the other steps of this guide: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04 如果您完成了本指南的其他步骤,您的服务将会正常运行: https//www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx -酮的ubuntu-14-04

Remember you can check the status of the services with these commands: 请记住,您可以使用以下命令检查服务的状态:

systemctl status puma.service
systemctl status nginx

And you can debug using 'tail -f' with these log files: 您可以使用'tail -f'调试这些日志文件:

/home/deploy/appname/shared/log/puma.stderr.log
/home/deploy/appname/log/production.log
/var/log/nginx/error.log

That is correct. 那是对的。 You should use SystemD in Ubuntu 16.04 LTS. 您应该在Ubuntu 16.04 LTS中使用SystemD。 Here is the relevant Puma documentation and the provided sample service unit file: 以下是相关的Puma文档和提供的示例服务单元文件:

[Unit]
Description=Puma HTTP Server
After=network.target

# Uncomment for socket activation (see below)
# Requires=puma.socket

[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple

# Preferably configure a non-privileged user
# User=

# Specify the path to your puma application root
# WorkingDirectory=

# Helpful for debugging socket activation, etc.
# Environment=PUMA_DEBUG=1

# The command to start Puma
# Here we are using a binstub generated via:
# `bundle binstubs puma --path ./sbin`
# in the WorkingDirectory (replace <WD> below)
# You can alternatively use `bundle exec --keep-file-descriptors puma`
# ExecStart=<WD>/sbin/puma -b tcp://0.0.0.0:9292 -b ssl://0.0.0.0:9293?key=key.pem&cert=cert.pem

# Alternatively with a config file (in WorkingDirectory) and
# comparable `bind` directives
# ExecStart=<WD>/sbin/puma -C config.rb

Restart=always

[Install]
WantedBy=multi-user.target

This Problem occurs if you are running your production server on Ubuntu 15.04 or higher (eg. 16.04) as mentioned here . 如果您在此处提到的Ubuntu 15.04或更高版本(例如16.04)上运行生产服务器,则会出现此问题。

The following commands worked for me- 以下命令对我有用 -

$ sudo apt-get install upstart-sysv
$ sudo update-initramfs -u
$ reboot

Don't forget to reboot, otherwise, commands won't take affect. 不要忘记重启,否则命令不会生效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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