簡體   English   中英

無法在Ubuntu 16.04上運行Puma upstart腳本

[英]Cannot run Puma upstart script on Ubuntu 16.04

我正在嘗試手動啟動我的Ruby on Rails應用程序,但遇到了問題。

當運行'sudo start puma-manager'或'sudo start puma app = / home //'時,我收到以下錯誤:'無法連接到Upstart:無法連接到socket / com / ubuntu / upstart:連接被拒絕”。

我正在閱讀本教程: 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我已經按照本教程的最后細節)。 是否有一個很好的方法讓新手上班?

我剛才讀到16.04沒有新貴。 真的嗎? 我發現很難相信美洲獅沒有一個好的解決方法。 這似乎太常見了。

謝謝你的幫助!

我有同樣的問題,有一段時間這是我沒有升級到Ubuntu 16的原因,但我們必須繼續這個變化。 Systemd可能很嚇人,但是一旦你開始有設置服務腳本的經驗,它可能比Upstart更容易。

  1. 在/ 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. 運行這些命令以啟動systemd服務。

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

如果您完成了本指南的其他步驟,您的服務將會正常運行: https//www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx -酮的ubuntu-14-04

請記住,您可以使用以下命令檢查服務的狀態:

systemctl status puma.service
systemctl status nginx

您可以使用'tail -f'調試這些日志文件:

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

那是對的。 您應該在Ubuntu 16.04 LTS中使用SystemD。 以下是相關的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

如果您在此處提到的Ubuntu 15.04或更高版本(例如16.04)上運行生產服務器,則會出現此問題。

以下命令對我有用 -

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

不要忘記重啟,否則命令不會生效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM