捆绑器:加载命令失败:sidekiq -> systemd

bundler: failed to load command: sidekiq -> systemd

我已经厌倦了在 ubuntu 上设置 sidekiq 通过使用 rvm、capistrano gem、capistrano-sidekiq gem、sidekiq gem、redis gem

这是我的sidekiq.service文件(官方写的example):

[Unit]
Description=sidekiq
After=syslog.target network.target

[Service]
Type=notify
WatchdogSec=10

WorkingDirectory=/home/deploy/my_platform/current
ExecStart=/home/deploy/.rvm/gems/ruby-3.0.0@r611/wrappers/bundle exec sidekiq -e production

User=deploy
Group=deploy
UMask=0002

Environment=MALLOC_ARENA_MAX=2

RestartSec=1
Restart=on-failure

StandardOutput=syslog
StandardError=syslog

SyslogIdentifier=sidekiq

[Install]
WantedBy=multi-user.target

(当然,我在我的 RVM 中设置了 3.0.0 ruby 和自定义 r611 gem,它们成功运行)

$ systemctl enable sidekiq
$ systemctl start sidekiq

但是当我尝试启动此服务时 - 它不起作用:

Job for sidekiq.service failed because the control process exited with error code.
See "systemctl status sidekiq.service" and "journalctl -xe" for details.

如果我们尝试检查日志 - 我们会看到:

$ journalctl -u sidekiq
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]: bundler: failed to load command: sidekiq (/home/deploy/my_platform/shared/bundle/ruby/3.0.0/bin/sidekiq)
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]: /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/rubygems_integration.rb:362:in `block in replace_bin_path': can't find executable sidekiq for gem sidekiq. sidekiq is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/rubygems_integration.rb:390:in `block in replace_bin_path'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/my_platform/shared/bundle/ruby/3.0.0/bin/sidekiq:23:in `<top (required)>'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:63:in `load'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:63:in `kernel_load'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:28:in `run'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:494:in `exec'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:30:in `dispatch'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:24:in `start'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/exe/bundle:49:in `block in <top (required)>'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/bundler/friendly_errors.rb:130:in `with_friendly_errors'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/exe/bundle:37:in `<top (required)>'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/gems/ruby-3.0.0@r611/bin/bundle:23:in `load'
Apr 04 19:08:06 ubuntu-s-1vcpu-1gb-nyc1-01 sidekiq[14639]:         from /home/deploy/.rvm/gems/ruby-3.0.0@r611/bin/bundle:23:in `<main>'

包在我的 rvm 中说了什么 gem设置:

~/my_platform$ bundle info sidekiq
  * sidekiq (6.2.0)
    Summary: Simple, efficient background processing for Ruby
    Homepage: https://sidekiq.org
    Documentation: https://github.com/mperham/sidekiq/wiki
    Source Code: https://github.com/mperham/sidekiq
    Changelog: https://github.com/mperham/sidekiq/blob/master/Changes.md
    Bug Tracker: https://github.com/mperham/sidekiq/issues
    Path: /home/deploy/.rvm/gems/ruby-3.0.0@r611/gems/sidekiq-6.2.0

我很困惑,为什么它不起作用并且不明白如何在终端中没有一些可读信息的情况下修复它。因为我的 Gemfile 有 sidekiq gem 并且我可以手动成功使用它。

如果您使用 capistrano - 这一行:

WorkingDirectory=/home/deploy/my_platform/current

应该是:

WorkingDirectory=/home/deploy/my_platform