Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add args for systemd #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions lib/capistrano/tasks/sidekiq.rake
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,13 @@ namespace :sidekiq do
end

def start_sidekiq(pid_file, idx = 0)
execute :sidekiq, execute_args(pid_file: pid_file, idx: idx, daemon: true)
end

def execute_args(options = {})
args = []
args.push "--index #{idx}"
args.push "--pidfile #{pid_file}"
args.push "--index #{options[:idx]}" if options[:idx]
args.push "--pidfile #{options[:pid_file]}" if options[:pid_file]
args.push "--environment #{fetch(:sidekiq_env)}"
args.push "--logfile #{fetch(:sidekiq_log)}" if fetch(:sidekiq_log)
args.push "--require #{fetch(:sidekiq_require)}" if fetch(:sidekiq_require)
Expand All @@ -250,19 +254,21 @@ namespace :sidekiq do
args.push "--config #{fetch(:sidekiq_config)}" if fetch(:sidekiq_config)
args.push "--concurrency #{fetch(:sidekiq_concurrency)}" if fetch(:sidekiq_concurrency)
if (process_options = fetch(:sidekiq_options_per_process))
args.push process_options[idx]
args.push process_options[options[:idx]]
end
# use sidekiq_options for special options
args.push fetch(:sidekiq_options) if fetch(:sidekiq_options)

if defined?(JRUBY_VERSION)
args.push '>/dev/null 2>&1 &'
warn 'Since JRuby doesn\'t support Process.daemon, Sidekiq will not be running as a daemon.'
else
args.push '--daemon'
if options[:daemon]
if defined?(JRUBY_VERSION)
args.push '>/dev/null 2>&1 &'
warn 'Since JRuby doesn\'t support Process.daemon, Sidekiq will not be running as a daemon.'
else
args.push '--daemon'
end
end

execute :sidekiq, args.compact.join(' ')
args.compact.join(' ')
end

def switch_user(role)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=syslog.target network.target
Type=simple
Environment=RAILS_ENV=<%= fetch(:rails_env) %>
WorkingDirectory=<%= fetch(:deploy_to) %>/current
ExecStart=<%= fetch(:bundler_path, '/usr/local/bin/bundler') %> exec sidekiq -e <%= fetch(:rails_env) %>
ExecStart=<%= fetch(:bundler_path, '/usr/local/bin/bundler') %> exec sidekiq <%= execute_args %>
ExecReload=/bin/kill -TSTP $MAINPID
ExecStop=/bin/kill -TERM $MAINPID

Expand Down