没有这样的文件或目录@ rb_sysopen - tmp/pids/puma.pid

No such file or directory @ rb_sysopen - tmp/pids/puma.pid

我正在尝试启动 puma,但在最后一步失败,如下所示:

16:38:09 web.1  | /home/ramonpm/.rvm/gems/ruby-2.2.7/gems/puma-3.9.1/lib/puma/launcher.rb:130:in `initialize': No such file or directory @ rb_sysopen - tmp/pids/puma.pid (Errno::ENOENT)
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/gems/puma-3.9.1/lib/puma/launcher.rb:130:in `open'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/gems/puma-3.9.1/lib/puma/launcher.rb:130:in `write_pid'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/gems/puma-3.9.1/lib/puma/launcher.rb:103:in `write_state'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/gems/puma-3.9.1/lib/puma/single.rb:92:in `run'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/gems/puma-3.9.1/lib/puma/launcher.rb:174:in `run'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/gems/puma-3.9.1/lib/puma/cli.rb:77:in `run'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/gems/puma-3.9.1/bin/puma:10:in `<top (required)>'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/bin/puma:23:in `load'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/bin/puma:23:in `<main>'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/bin/ruby_executable_hooks:15:in `eval'
16:38:09 web.1  |   from /home/ramonpm/.rvm/gems/ruby-2.2.7/bin/ruby_executable_hooks:15:in `<main>'
16:38:09 web.1  | exited with code 1
16:38:09 system | sending SIGTERM to all processes

无法在其他地方找到解决方案,它们都与不同的事物有关。

可以解决手动创建必要的文件夹,然后服务器进程可以创建pid文件。

mkdir -p tmp/pids

您可以在 config/puma.rb 中添加:

require "fileutils"
FileUtils.mkdir_p("tmp/pids")

当我第一次通过 rails app:update 添加 puma.rb 文件到 Heroku 应用程序的 rails 5.2 时发生此错误。

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

通过添加 tmp/pids/.keep 文件解决,

$ touch tmp/pids/.keep

并更新 .gitignore 文件如下。

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep