首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Redis和Sidekiq在Ubuntu 16.04上使用systemd进行生产,并使用Capistrano进行部署

Redis和Sidekiq在Ubuntu 16.04上使用systemd进行生产,并使用Capistrano进行部署
EN

Stack Overflow用户
提问于 2018-12-04 17:36:58
回答 1查看 2.5K关注 0票数 3

我在ubuntu 16.04中使用systemd service和Capistrano部署sidekiq。

Sidekiq系统服务文件/lib/systemd/ system /idekiq.service

代码语言:javascript
复制
#
# systemd unit file for CentOS 7, Ubuntu 15.04
#
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# Run:
#   - systemctl enable sidekiq
#   - systemctl {start,stop,restart} sidekiq
#
# This file corresponds to a single Sidekiq process.  Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
#
# See Inspeqtor's Systemd wiki page for more detail about Systemd:
# https://github.com/mperham/inspeqtor/wiki/Systemd
#
[Unit]
Description=sidekiq
# start us only once the network and logging subsystems are available,
# consider adding redis-server.service if Redis is local and systemd-managed.
After=syslog.target network.target

# See these pages for lots of options:
# http://0pointer.de/public/systemd-man/systemd.service.html
# http://0pointer.de/public/systemd-man/systemd.exec.html
[Service]
Type=simple
WorkingDirectory=/opt//current
# If you use rbenv:
# ExecStart=/bin/bash -lc 'bundle exec sidekiq -e production'
# If you use the system's ruby:
ExecStart=/usr/local/bin/bundle exec sidekiq -e production -C config/sidekiq.yml -L log/sidekiq.log
User=deploy
Group=deploy
UMask=0002

# if we crash, restart
RestartSec=1
Restart=on-failure

# output goes to /var/log/syslog
StandardOutput=syslog
StandardError=syslog

# This will default to "bundler" if we don't specify it
SyslogIdentifier=sidekiq

[Install]
WantedBy=multi-user.target

但是当使用下面的命令启动sidekiq服务时,它不会显示任何错误:

代码语言:javascript
复制
sudo systemctl start/stop sidekiq

在它的状态下抛出一个错误,退出代码为sudo systemctl status sidekiq

代码语言:javascript
复制
● sidekiq.service - sidekiq
   Loaded: loaded (/lib/systemd/system/sidekiq.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2018-12-04 01:24:39 PST; 754ms ago
  Process: 28133 ExecStart=/usr/local/bin/bundle exec sidekiq -e production -C config/sidekiq.yml -L log/sidekiq.log (code=exited, status=217/US
 Main PID: 28133 (code=exited, status=217/USER)

Dec 04 01:24:39 tt-apps-05 systemd[1]: sidekiq.service: Unit entered failed state.
Dec 04 01:24:39 tt-apps-05 systemd[1]: sidekiq.service: Failed with result 'exit-code'.

Bundler出现在

代码语言:javascript
复制
tt-apps-05:/usr/local/bin$ ls
autopep8       drt-open                    mod_passenger.so  pygal_gen.pyc  rst2latex.py           sphinx-apidoc
bundle         drt-query                   netaddr       pygmentize rst2man.py         sphinx-autogen
bundler        drt-unassigned                  nosetests     query-pr   rst2odt_prepstyles.py  sphinx-build

Capistrno deploy.rb

代码语言:javascript
复制
set :user, "deploy"

Rake::Task["sidekiq:stop"].clear_actions
Rake::Task["sidekiq:start"].clear_actions
Rake::Task["sidekiq:restart"].clear_actions
namespace :sidekiq do
  task :stop do
    on roles(:app) do
      execute :sudo, :systemctl, :stop, :sidekiq
    end
  end
  task :start do
    on roles(:app) do
      execute :sudo, :systemctl, :start, :sidekiq
    end
  end
  task :restart do
    on roles(:app) do
      execute :sudo, :systemctl, :restart, :sidekiq
    end
  end
end

我不知道问题出在哪里,有人能帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2020-07-21 01:28:14

试试这个:

代码语言:javascript
复制
ExecStart=/bin/bash -lc "/usr/local/bin/bundle exec sidekiq -e production -C config/sidekiq.yml -L log/sidekiq.log"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53609754

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档