1

I have a cuba application which I want to use sidekiq with.

This is how I setup the 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)

I started sidekiq using systemd. This is the systemd script which I adapted from the sidekiq.service on the sidekiq site.:

#
# 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

The code calling the worker is :

 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

I am only using the default q.

My problem is that the job is not being processed at all.

froy001
  • 614
  • 7
  • 21

1 Answers1

4

After you run systemctl enable sidekiq so that it starts at boot and systemctl start sidekiq so that it starts immediately, then you should have some logs to review which will provide some detail about any failure to start:

 sudo journalctl -u sidekiq

Review the logs, review the systemd docs and adjust your unit file as needed. You can find all the installed systemd documentation with apropos systemd. Some of the most useful man pages to review are systemd.service,systemd.exec and systemd.unit

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49
  • I went over the files, and the man pages. It seem that the server starts ok, it is running and no errors are being outputted to the logs. It is as if the sidekiq server isn't listening. Any suggestions? – froy001 Oct 04 '16 at 10:01
  • you can use `ps` to confirm the process is running, check your firewall rules, try to connect directly to the port or socket from inside the machine. – Mark Stosberg Oct 04 '16 at 14:58
  • It all checks out. I guess I will go on digging since nothing stands out. Naturally, if you happen to have a moment of enlightenment and you remember some dark corner of the setup process, I would appreciate if you drop a line. – froy001 Oct 05 '16 at 08:08