Skip to content

Commit 6f6032a

Browse files
committed
Initial Commit
0 parents  commit 6f6032a

File tree

6 files changed

+103
-0
lines changed

6 files changed

+103
-0
lines changed

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in capistrano-rvm.gemspec
4+
gemspec

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require "bundler/gem_tasks"

capistrano-clockwork.gemspec

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
lib = File.expand_path('../lib', __FILE__)
2+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3+
4+
Gem::Specification.new do |s|
5+
s.name = 'capistrano-clockwork'
6+
s.version = '0.0.2'
7+
s.date = '2015-05-12'
8+
s.summary = "Capistrano plugin to manage clockwork"
9+
s.description = "Capistrano plugin to manage clockwork"
10+
s.authors = ["Suraj Shirvankar"]
11+
s.email = '[email protected]'
12+
s.files = ["lib/capistrano-clockwork.rb"]
13+
s.homepage = "http://github.com/h0lyalg0rithm/capistrano-clockwork"
14+
s.license = 'MIT'
15+
16+
s.files = `git ls-files`.split($/)
17+
s.require_path= ["lib"]
18+
s.add_dependency 'capistrano', '~> 3.1'
19+
end

lib/capistrano-clockwork.rb

Whitespace-only changes.

lib/capistrano/clockwork.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
load File.expand_path("../tasks/capistrano-clockwork.rake", __FILE__)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
namespace :load do
2+
task :defaults do
3+
set :clockwork_default_hooks, -> { true }
4+
set :clockwork_file, -> { "lib/clockwork.rb" }
5+
end
6+
end
7+
8+
namespace :deploy do
9+
before :starting, :check_sidekiq_hooks do
10+
invoke 'clockwork:add_default_hooks' if fetch(:clockwork_default_hooks)
11+
end
12+
after :publishing, :restart_sidekiq do
13+
invoke 'clockwork:restart' if fetch(:clockwork_default_hooks)
14+
end
15+
end
16+
17+
namespace :clockwork do
18+
desc "Stop clockwork"
19+
task :stop do
20+
on roles(:app) do
21+
within release_path do
22+
with rails_env: fetch(:rails_env) do
23+
execute :bundle, :exec, :clockworkd, "-c #{fetch(:clockwork_file)} --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} --log stop"
24+
end
25+
end
26+
end
27+
end
28+
29+
desc "Clockwork status"
30+
task :status do
31+
on roles(:app) do
32+
within release_path do
33+
with rails_env: fetch(:rails_env) do
34+
execute :bundle, :exec, :clockworkd, "-c #{fetch(:clockwork_file)} --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} --log status"
35+
end
36+
end
37+
end
38+
end
39+
40+
desc "Start clockwork"
41+
task :start do
42+
on roles(:app) do
43+
within release_path do
44+
with rails_env: fetch(:rails_env) do
45+
execute :bundle, :exec, :clockworkd, "-c #{fetch(:clockwork_file)} --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} --log start"
46+
end
47+
end
48+
end
49+
end
50+
51+
desc "Restart clockwork"
52+
task :restart do
53+
on roles(:app) do
54+
within release_path do
55+
with rails_env: fetch(:rails_env) do
56+
execute :bundle, :exec, :clockworkd, "-c #{fetch(:clockwork_file)} --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} --log restart"
57+
end
58+
end
59+
end
60+
end
61+
62+
def cw_log_dir
63+
"#{shared_path}/log"
64+
end
65+
def cw_pid_dir
66+
"#{shared_path}/tmp/pids"
67+
end
68+
69+
def rails_env
70+
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
71+
end
72+
73+
task :add_default_hooks do
74+
after 'deploy:stop', 'clockwork:stop'
75+
after 'deploy:start', 'clockwork:start'
76+
after 'deploy:restart', 'clockwork:restart'
77+
end
78+
end

0 commit comments

Comments
 (0)