Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

convert delayed_job recipe to systemd

  • Loading branch information...
commit 7bc7b545bf7f0b2f6fa391a870abd0c3db442a62 1 parent a7d6c66
Benedikt Böhm hollow authored
27 README.rst
View
@@ -82,24 +82,12 @@ The above command will upload ``config/deploy/templates/myscript.sh.erb`` to
the specified path. Inside the template all capistrano options (current_path,
application, etc) are available.
-Monit integration
+systemd integration
-----------------
-Capper provides DSL syntax for monit integration. Many recipes shipped with
-capper already contain monit configuration. These configuration snippets are
-not enabled unless you include the monit recipe in your ``Capfile``.
-
-Custom monit configuration snippets can be created with ``monit_config``::
-
- monit_config "myprocess", <<EOF, :roles => :app
- check process myprocess
- with pidfile ...
- start program = ...
- stop program = ...
- EOF
-
-The above call will create the specified monit snippet for monit instances
-running on servers in the ``:app`` role.
+Capper provides integration with a systemd user session running for the user
+that is being deployed to. Capper will upload service units and enable/start
+these accordingly.
Recipes
=======
@@ -188,13 +176,6 @@ django
The django recipe provides setup and migrate tasks for Django.
-monit
------
-
-The monit recipe will collect all snippets declared via ``monit_config`` and
-render them into the file specified via ``monitrc`` (default:
-``~/.monitrc.local``, this file should be included in your ``~/.monitrc``).
-
python
------
50 lib/capper/delayed_job.rb
View
@@ -3,25 +3,12 @@
# these cannot be overriden
set(:delayed_job_script) { File.join(bin_path, "delayed_job") }
+set(:delayed_job_service) { File.join(units_path, "delayed_job.service") }
after "deploy:update_code", "delayed_job:setup"
-after "deploy:restart", "delayed_job:restart"
-
-monit_config "delayed_job", <<EOF.dedent, :roles => :worker
- <% delayed_job_workers.each do |name, range| %>
- check process delayed_job_<%= name %>
- with pidfile <%= pid_path %>/delayed_job.<%= name %>.pid
- <% if range.nil? %>
- start program = "<%= delayed_job_script %> start <%= name %>"
- stop program = "<%= delayed_job_script %> stop <%= name %>"
- <% else %>
- start program = "<%= delayed_job_script %> start <%= name %> <%= range.begin %> <%= range.end %>"
- stop program = "<%= delayed_job_script %> stop <%= name %> <%= range.begin %> <%= range.end %>"
- <% end %>
- group delayed_job
-
- <% end %>
-EOF
+after "deploy:restart", "delayed_job:upgrade"
+after "deploy:start", "delayed_job:start"
+after "deploy:stop", "delayed_job:stop"
namespace :delayed_job do
desc "Generate DelayedJob configuration files"
@@ -29,12 +16,33 @@
upload_template_file("delayed_job.sh",
delayed_job_script,
:mode => "0755")
+ upload_template_file("delayed_job@.service",
+ delayed_job_service,
+ :mode => "0755")
+ systemctl "daemon-reload"
+ delayed_job_worker.each do |name|
+ systemctl :enable, "delayed_job@#{name}"
+ end
+ end
+
+ desc "Start delayed job workers"
+ task :start, :roles => :app, :except => { :no_release => true } do
+ delayed_job_worker.each do |name|
+ systemctl :start, "delayed_job@#{name}"
+ end
+ end
+
+ desc "Stop delayed job workers"
+ task :stop, :roles => :app, :except => { :no_release => true } do
+ delayed_job_worker.each do |name|
+ systemctl :stop, "delayed_job@#{name}"
+ end
end
- desc "Restart DelayedJob workers"
- task :restart, :roles => :worker, :except => { :no_release => true } do
- if fetch(:monitrc, false)
- run "monit -g delayed_job restart all"
+ desc "Restart delayed job workers"
+ task :restart, :roles => :app, :except => { :no_release => true } do
+ delayed_job_worker.each do |name|
+ systemctl :restart, "delayed_job@#{name}"
end
end
end
11 lib/capper/templates/delayed_job.service.erb
View
@@ -0,0 +1,11 @@
+[Unit]
+Description=Delayed Job Worker (%I)
+
+[Service]
+Type=forking
+PIDFile=<%= pid_path %>/delayed_job.%I.pid
+ExecStart=<%= delayed_job_script %> start %I
+ExecStop=<%= delayed_job_script %> stop %I
+
+[Install]
+WantedBy=default.target
Please sign in to comment.
Something went wrong with that request. Please try again.