Ubuntu 在后台运行 Puma 和 Sidekiq 作为守护进程

问题描述

两年前,我运行了以下命令:

bundle exec puma -C config/puma.rb -b unix:/home/user/site/shared/tmp/sockets/user-puma.sock -d
bundle exec sidekiq -d

但是现在,在一些 Ubuntu 更新之后,-d 标志已被弃用,我无法启动 Puma 和 Sidekiq 进程以在后台运行。

我也试过跑步:

bundle exec puma -C config/puma.rb -b unix:/home/user/site/shared/tmp/sockets/user-puma.sock &
bundle exec sidekiq &

这仅在我登录 SSH 时有效,当我关闭 SSH 连接时,所有使用 & 打开的进程都将关闭

如何在后台运行 Puma、Sidekiq 和其他进程作为守护进程?

解决方法

对我有用的是为 sidekiq 设置我自己的 systemd 服务

一个详细记录的示例文件位于 the sidekiq github repository

除此之外,我还建议使用 monit 来监视后台进程... here's a recipe from Lugo Labs,我的部署松散地基于此