2016-10-03 27 views
1

我有一个古巴应用程序,我想使用sidekiq。Sidekiq服务器在开始使用systemd时未处理预定作业

这是我如何设置的config.ru:

require './app' 
require 'sidekiq' 
require 'sidekiq/web' 

environment = ENV['RACK_ENV'] || "development" 
config_vars = YAML.load_file("./config.yml")[environment] 

Sidekiq.configure_client do |config| 
    config.redis = { :url => config_vars["redis_uri"] } 
end 

Sidekiq.configure_server do |config| 
    config.redis = { url: config_vars["redis_uri"] } 
    config.average_scheduled_poll_interval = 5 
end 

# run Cuba 
run Rack::URLMap.new('/' => Cuba, '/sidekiq' => Sidekiq::Web) 

我使用systemd开始sidekiq。这是我改编自上sidekiq网站sidekiq.service的systemd脚本。:

# 
# 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 
Environment=RACK_ENV=development 
WorkingDirectory=/media/temp/bandmanage/repos/fall_prediction_verification 
# If you use rbenv: 
#ExecStart=/bin/bash -lc 'pwd && bundle exec sidekiq -e production' 
ExecStart=/home/froy001/.rvm/wrappers/fall_prediction/bundle exec "sidekiq -r app.rb -L log/sidekiq.log -e development" 
# If you use the system's ruby: 
#ExecStart=/usr/local/bin/bundle exec sidekiq -e production 
User=root 
Group=root 
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 

调用工人的代码是:

raw_msg = JSON.parse(req.body.read, {:symbolize_names => true}) 
      if raw_msg 
      ts = raw_msg[:ts] 
      waiting_period = (1000*60*3) # wait 3 min before checking 
      perform_at_time = Time.at((ts + waiting_period)/1000).utc 

      FallVerificationWorker.perform_at((0.5).minute.from_now, raw_msg) 

      my_res = { result: "success", status: 200}.to_json 
      res.status = 200 
      res.write my_res 
      else 
      my_res = { result: "not found", status: 404}.to_json 
      res.status = 404 
      res.write my_res 
      end 

我只使用默认的Q值。

我的问题是该作业根本没有被处理。

回答

3

在运行systemctl enable sidekiq,以便它开始于引导和systemctl start sidekiq,使其立即启动,那么你应该有一些日志审查,这将提供有关任何失败的开始一些细节:

sudo journalctl -u sidekiq 

回顾日志,查看systemd文档并根据需要调整您的单元文件。您可以使用apropos systemd找到所有已安装的systemd文档。一些最有用的手册页审查systemd.servicesystemd.execsystemd.unit

+0

我去了文件,和手册页。看起来服务器启动正常,它正在运行并且没有错误输出到日志。就好像sidekiq服务器没有在监听。有什么建议么? – froy001

+0

您可以使用'ps'确认进程正在运行,检查您的防火墙规则,尝试从机器内部直接连接到端口或套接字。 –

+0

这一切都检查出来。我想我会继续挖掘,因为没有什么突出的。当然,如果你碰巧有启发的时刻,并且你还记得设置过程中的一些黑暗角落,如果你放下一条线,我会很感激。 – froy001

相关问题