在Ubuntu 16.04上将Rails Sidekiq作为系统服务运行

时间:2018-08-09 07:28:05

标签: ruby-on-rails ruby ubuntu-16.04 bundler sidekiq

我对系统有以下要求:

  1. Ubuntu 16.04
  2. ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
  3. Rails 4.2.5

我可以在项目内运行命令bundle exec sidekiq -q queue,而不会出错。不幸的是,当我尝试使用以下文件名single_profile_crawl_worker.service创建系统服务时:

[Unit]
Description=sidekiq

[Service]
WorkingDirectory=/home/jaisanas/Documents/work/myproject
ExecStart=/home/jaisanas/.rvm/gems/ruby-2.2.1@scraper/bin/bundle exec sidekiq -q tahilalat

[Install]
WantedBy=multi-user.target

然后我运行命令:

  

sudo systemctl start single_profile_crawl_worker.service

然后当我通过以下命令检查服务状态时:

  

sudo systemctl状态single_profile_crawl_worker.service

它返回如下错误:

single_profile_crawl_worker.service - sidekiq
 Loaded: loaded (/etc/systemd/system/single_profile_crawl_worker.service; disabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Kam 2018-08-09 14:13:43 WIB; 5s ago
      Process: 9822 ExecStart=/home/jaisanas/.rvm/gems/ruby-2.2.1@scraper/bin/bundle exec sidekiq -q tahilalat (code=exited, status=127)
     Main PID: 9822 (code=exited, status=127)

    Agu 09 14:13:43 jaisanas-X456URK systemd[1]: Started sidekiq.
    Agu 09 14:13:43 jaisanas-X456URK bundle[9822]: /usr/bin/env: ‘ruby_executable_hooks’: No such file or directory
    Agu 09 14:13:43 jaisanas-X456URK systemd[1]: single_profile_crawl_worker.service: Main process exited, code=exited, status=127/n/a
    Agu 09 14:13:43 jaisanas-X456URK systemd[1]: single_profile_crawl_worker.service: Unit entered failed state.
    Agu 09 14:13:43 jaisanas-X456URK systemd[1]: single_profile_crawl_worker.service: Failed with result 'exit-code'.

它说/usr/bin/env: ‘ruby_executable_hooks’: No such file or directory。然后,我尝试了几种解决方案,例如通过运行sudo gem install --user-install executable-hooks安装ruby_executable_hooks无法正常工作,有人知道我创建此sidekiq系统服务的步骤出了什么问题吗?

0 个答案:

没有答案