【问题标题】:How to start Unicorn with systemctl and systemd如何使用 systemctl 和 systemd 启动 Unicorn
【发布时间】:2020-11-25 11:10:35
【问题描述】:

我想在 amazon-linux-2 上用 systemctl 启动 Unicorn,但 Unicorn 没有启动。

我写了一个 /etc/systemd/system/unicorn.service 文件。

[Unit]
Description=The unicorn process

[Service]
User=myname
WorkingDirectory=/var/www/rails/myapp
SyslogIdentifier=unicorn
Type=simple

ExecStart=/bin/bash -l -c 'bundle exec unicorn_rails -c /var/www/rails/myapp/config/unicorn.conf.rb -E production -D'

[Install]
WantedBy=multi-user.target

这是我用来启动服务的命令

sudo systemctl daemon-reload
sudo systemctl start unicorn.service

我用命令ps -ef | grep unicorn | grep -v grep找不到任何关于独角兽的进程。

我在这里查看状态:

$ sudo systemctl status unicorn -l
● unicorn.service - The unicorn process
   Loaded: loaded (/etc/systemd/system/unicorn.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

xxx.compute.internal systemd[1]: Started The unicorn process.
xxx.compute.internal systemd[1]: Starting The unicorn process...

这里是 unicorn.log。 (没有任何错误日志)

I, [2020-11-25T20:00:24.564840 #6604]  INFO -- : Refreshing Gem list
I, [2020-11-25T20:00:25.278814 #6604]  INFO -- : unlinking existing socket=/var/www/rails/myapp/tmp/sockets/.unicorn.sock
I, [2020-11-25T20:00:25.279020 #6604]  INFO -- : listening on addr=/var/www/rails/myapp/tmp/sockets/.unicorn.sock fd=9
I, [2020-11-25T20:00:25.299977 #6604]  INFO -- : master process ready
I, [2020-11-25T20:00:25.406567 #6604]  INFO -- : reaped #<Process::Status: pid 6607 exit 0> worker=0
I, [2020-11-25T20:00:25.406659 #6604]  INFO -- : reaped #<Process::Status: pid 6608 exit 0> worker=1
I, [2020-11-25T20:00:25.406760 #6604]  INFO -- : master complete

为什么独角兽不启动?

【问题讨论】:

    标签: amazon-ec2 systemd unicorn autostart amazon-linux-2


    【解决方案1】:

    Type=simple 更改为Type=forking

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-06
      • 2019-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-15
      相关资源
      最近更新 更多