0.1
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
Adds tasks to aid in the deployment of Sidekiq
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 1.0.2
 Project Readme

mina-sidekiq

mina-sidekiq is a gem that adds tasks to aid in the deployment of Sidekiq using Mina.

Starting with 1.0.0 this gem requires Mina 1.0! (thanks @devvmh)

Support sidekiq > 6.0, reference project capistrano-sidekiq, github: https://github.com/seuros/capistrano-sidekiq

Getting Start

Installation

gem install mina-sidekiq

Example

require 'mina_sidekiq/tasks'
#...

task :setup do
  # sidekiq needs a place to store its pid file and log file
  command %(mkdir -p "#{fetch(:deploy_to)}/shared/pids/")
  command %(mkdir -p "#{fetch(:deploy_to)}/shared/log/")
end

task :deploy do
  deploy do
    # stop accepting new workers
    invoke :'git:clone'
    invoke :'sidekiq:quiet'
    invoke :'deploy:link_shared_paths'
    ...

    on :launch do
      ...
      invoke :'sidekiq:restart'
    end
  end
end

Support sidekiq > 6.0

Set init system to systemd in the mina deploy config:

  set :init_system, :systemd

Enable lingering for systemd user account

  loginctl enable-linger USERACCOUNT

Install systemd.service template file and enable the service with:

  bundle exec mina sidekiq:install

Default name for the service file is sidekiq-env.service. This can be changed as needed, for example:

  set :service_unit_name, "sidekiq-#{fetch(:rails_env)}.service"

Default systemctl command is systemctl --user, this can be changed, for example:

  set :systemctl_command, 'systemctl --user'

For non privileged user (non sudo) usage set up path for systemctl unit file:

  set :service_unit_path, '/home/www/.config/systemd/user'

where www is the username. For details see systemctl doc page

To use systemctl integration with rbenv bundler path must be setted:

  set :bundler_path, '/home/www/.rbenv/shims/bundler'

To get bundler path use:

  which bundler

Integration with upstart

Set init system to upstart in the cap deploy config:

  set :init_system, :upstart

Set upstart service name:

  set :upstart_service_name, 'sidekiq'

Available Tasks

  • sidekiq:stop
  • sidekiq:start
  • sidekiq:restart
  • sidekiq:quiet
  • sidekiq:log

sidekiq > 6.0

  • sidekiq:install
  • sidekiq:uninstall

Available Options

Option Description
sidekiq Sets the path to sidekiq.
sidekiqctl Sets the path to sidekiqctl.
sidekiq_timeout Sets a upper limit of time a worker is allowed to finish, before it is killed.
sidekiq_log Sets the path to the log file of sidekiq.
sidekiq_pid Sets the path to the pid file of a sidekiq worker.
sidekiq_processes Sets the number of sidekiq processes launched.
sidekiq_config Sets the config file path.
sidekiq_configs Sets the config file paths when using more than one sidekiq process with different configuration.

Testing

The test requires a local running ssh server with the ssh keys of the current user added to its ~/.ssh/authorized_keys. In OS X, this is "Remote Login" under the Sharing pref pane. You will also need a working rvm installation.

To run the full blown test suite use:

bundle exec rake test

For faster release cycle use

cd test_env
bundle exec mina deploy --verbose

Copyright

Copyright (c) 2016 Jörg Thalheim joerg@higgsboson.tk

See LICENSE for further details.