【问题标题】:Failure to restart puma after capistrano deploymentcapistrano 部署后无法重启 puma
【发布时间】:2021-12-18 11:19:56
【问题描述】:

我正在尝试使用 capistrano 将 rails 应用程序从我的机器部署到 aws linux ec2。

我使用了bundle exec cap production deploy 命令,它实际上成功地向服务器部署了一个新版本,但它无法(重新)启动 puma。在 puma 重启阶段,我收到此错误(出于隐私考虑,我将错误中的实际应用名称替换为 ):

01:23 puma:restart
      01 sudo /bin/systemctl restart puma_<app-name>_production
      01 Failed to restart puma_<app-name>_production.service: Unit puma_<app-name>_production.service not found.
      01
#<Thread:0x00007f93fb8d2700@/Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        12: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
        11: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:31:in `run'
        10: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
         9: from /Users/sary/.rvm/gems/ruby-2.6.4/bundler/gems/capistrano-puma-f9801f6762d1/lib/capistrano/tasks/systemd.rake:105:in `block (3 levels) in eval_rakefile'
         8: from /Users/sary/.rvm/gems/ruby-2.6.4/bundler/gems/capistrano-puma-f9801f6762d1/lib/capistrano/puma/systemd.rb:55:in `execute_systemd'
         7: from /Users/sary/.rvm/gems/ruby-2.6.4/bundler/gems/capistrano-puma-f9801f6762d1/lib/capistrano/puma/systemd.rb:48:in `sudo_if_needed'
         6: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/capistrano-3.12.0/lib/capistrano/dsl.rb:44:in `sudo'
         5: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:80:in `execute'
         4: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
         3: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:148:in `tap'
         2: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
         1: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/backends/netssh.rb:170:in `execute_command'
/Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/command.rb:97:in `exit_status=': sudo exit status: 5 (SSHKit::Command::Failed)
sudo stdout: Failed to restart puma_<app-name>_production.service: Unit puma_<app-name>_production.service not found.
sudo stderr: Nothing written
        1: from /Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/sary/.rvm/gems/ruby-2.6.4/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing on host 54.78.252.112: sudo exit status: 5 (SSHKit::Runner::ExecuteError)
sudo stdout: Failed to restart puma_<app-name>_production.service: Unit puma_<app-name>_production.service not found.
sudo stderr: Nothing written
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 54.78.252.112: sudo exit status: 5
sudo stdout: Failed to restart puma_<app-name>_production.service: Unit puma_<app-name>_production.service not found.
sudo stderr: Nothing written


Caused by:
SSHKit::Command::Failed: sudo exit status: 5
sudo stdout: Failed to restart puma_<app-name>_production.service: Unit puma_<app-name>_production.service not found.
sudo stderr: Nothing written

Tasks: TOP => puma:restart
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing on host 54.78.252.112: sudo exit status: 5
sudo stdout: Failed to restart puma_<app-name>_production.service: Unit puma_<app-name>_production.service not found.
sudo stderr: Nothing written


** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:

免责声明:我从以前的工程师那里继承了这个部署过程,所以 rails/puma/capistrano 不是我的专长。非常感谢任何帮助。

【问题讨论】:

    标签: ruby-on-rails capistrano puma


    【解决方案1】:

    您的生产服务器上似乎还没有 puma 服务单元文件。您可以在/etc/systemd/system/puma_&lt;app-name&gt;_production.service 创建一个。

    您应该在服务文件中添加一个单元条目。参考这个,https://gist.github.com/arteezy/5d53d99f6ee617fae1f0db0576fdd418

    一旦你创建了这个。下一步是测试此服务:

    $ systemctl start puma_<app_name>_production.service 
    $ systemctl status puma_<app_name>_production.service # Check status is running
    

    如果 puma 服务没有启动,请彻底检查服务文件中提到的路径。

    如果这种情况仍然存在,希望这能帮助您取得进步。

    【讨论】:

      猜你喜欢
      • 2021-07-20
      • 2015-06-15
      • 1970-01-01
      • 2020-08-11
      • 1970-01-01
      • 1970-01-01
      • 2018-08-24
      • 1970-01-01
      • 2013-06-30
      相关资源
      最近更新 更多