class Object
Public Instance Methods
create_systemd_template()
click to toggle source
# File lib/mina_sidekiq/tasks.rb, line 188 def create_systemd_template template = %{ [Unit] Description=sidekiq for #{fetch(:application)} #{fetch(:app_name)} After=syslog.target network.target [Service] Type=simple Environment=RAILS_ENV=#{ fetch(:rails_env) } StandardOutput=append:#{fetch(:deploy_to)}/current/log/sidekiq.log StandardError=append:#{fetch(:deploy_to)}/current/log/sidekiq.log WorkingDirectory=#{fetch(:deploy_to)}/current ExecStart=#{fetch(:bundler_path, '/usr/local/bin/bundler')} exec sidekiq -e #{fetch(:rails_env)} ExecReload=/bin/kill -TSTP $MAINPID ExecStop=/bin/kill -TERM $MAINPID RestartSec=1 Restart=on-failure SyslogIdentifier=sidekiq [Install] WantedBy=default.target } systemd_path = fetch(:service_unit_path, fetch_systemd_unit_path) service_path = systemd_path + "/" + fetch(:service_unit_name) comment %{Creating systemctl unit file} command %{ mkdir -p #{systemd_path} } command %{ touch #{service_path} } command %{ echo "#{ template }" > #{ service_path } } comment %{Reloading systemctl daemon} command %{ #{ fetch(:systemctl_command) } daemon-reload } comment %{Enabling sidekiq service} command %{ #{ fetch(:systemctl_command) } enable #{ service_path } } end
fetch_systemd_unit_path()
click to toggle source
# File lib/mina_sidekiq/tasks.rb, line 223 def fetch_systemd_unit_path home_dir = '/usr' File.join(home_dir, "lib", "systemd", "user") end
for_each_process() { |pid_file, idx| ... }
click to toggle source
# File lib/mina_sidekiq/tasks.rb, line 86 def for_each_process(&block) fetch(:sidekiq_processes).times do |idx| pid_file = if idx == 0 fetch(:sidekiq_pid) else "#{fetch(:sidekiq_pid)}-#{idx}" end yield(pid_file, idx) end end