在systemd上运行Ruby on Rails


1

操作系统:Centos 7

我正在尝试将Snorby作为systemd运行,但是脚本无法正确启动

在Snorby文件夹中时,我可以在命令行上将exec导轨服务器-e development -b 0.0.0.0捆绑在一起,没有任何问题,但是当我将其放在脚本中并使用systemctl执行时,它将无法正常工作。

[Service] WorkingDirectory=/tmp/snorby Environment=RAILS_ENV=development ExecStart=/usr/local/rbenv/shims/bundle exec rails server -d -b 0.0.0.0

状态输出

snorby.service - Snorby ConfiServ

Loaded: loaded (/usr/lib/systemd/system/snorby.service; enabled; vendor preset: disabled)

Active: inactive (dead) since Thu 2017-08-03 13:25:34 UTC; 1min 18s ago
  Process: 5533 ExecStart=/usr/local/rbenv/shims/bundle exec rails server -d -b 0.0.0.0 (code=exited, status=0/SUCCESS)
 Main PID: 5533 (code=exited, status=0/SUCCESS)

Aug 03 13:25:32 TEST-02 systemd[1]:   
 Started Snorby ConfiServ.

Aug 03 13:25:32 TEST-02 systemd[1]:  
 Starting Snorby ConfiServ...

Aug 03 13:25:34 TEST-02 bundle[5533]:  
 /usr/local/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-3.2.22/lib/action_dispatch/http/mime_type.rb:102: warning: already initialized constant Mime::PDF

Aug 03 13:25:34 TEST-02 bundle[5533]:  
 /usr/local/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-3.2.22/lib/action_dispatch/http/mime_type.rb:102: warning: previous definition of PDF was here  

Aug 03 13:25:34 TEST-02 bundle[5533]:  
  No time_zone specified in snorby_config.yml; detected time_zone: UTC

Aug 03 13:25:34 TEST-02 bundle[5533]: => Booting Thin

Aug 03 13:25:34 TEST-02 bundle[5533]: => Rails 3.2.22 application starting in development on http://0.0.0.0:3000

Answers:


1

就我而言,当我在如下脚本之前使用'bash -l'时,它可以工作。

ExecStart = / bin / bash -l'您的ruby命令或脚本'

我想centos 7在用systemd加载ruby环境变量时会遇到一些问题。它在没有-l选项的ubuntu上工作。


-2

我知道了-您需要在Systemd上启动Thin


1
请澄清此回答并为其添加更多背景信息,以更准确地传达您的建议,以便其他人清楚地了解您要解决的问题。
Pimp Juice IT
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.