forked from h0lyalg0rithm/capistrano-clockwork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6f6032a
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in capistrano-rvm.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "bundler/gem_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
|
||
Gem::Specification.new do |s| | ||
s.name = 'capistrano-clockwork' | ||
s.version = '0.0.2' | ||
s.date = '2015-05-12' | ||
s.summary = "Capistrano plugin to manage clockwork" | ||
s.description = "Capistrano plugin to manage clockwork" | ||
s.authors = ["Suraj Shirvankar"] | ||
s.email = '[email protected]' | ||
s.files = ["lib/capistrano-clockwork.rb"] | ||
s.homepage = "http://github.com/h0lyalg0rithm/capistrano-clockwork" | ||
s.license = 'MIT' | ||
|
||
s.files = `git ls-files`.split($/) | ||
s.require_path= ["lib"] | ||
s.add_dependency 'capistrano', '~> 3.1' | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
load File.expand_path("../tasks/capistrano-clockwork.rake", __FILE__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
namespace :load do | ||
task :defaults do | ||
set :clockwork_default_hooks, -> { true } | ||
set :clockwork_file, -> { "lib/clockwork.rb" } | ||
end | ||
end | ||
|
||
namespace :deploy do | ||
before :starting, :check_sidekiq_hooks do | ||
invoke 'clockwork:add_default_hooks' if fetch(:clockwork_default_hooks) | ||
end | ||
after :publishing, :restart_sidekiq do | ||
invoke 'clockwork:restart' if fetch(:clockwork_default_hooks) | ||
end | ||
end | ||
|
||
namespace :clockwork do | ||
desc "Stop clockwork" | ||
task :stop do | ||
on roles(:app) do | ||
within release_path do | ||
with rails_env: fetch(:rails_env) do | ||
execute :bundle, :exec, :clockworkd, "-c #{fetch(:clockwork_file)} --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} --log stop" | ||
end | ||
end | ||
end | ||
end | ||
|
||
desc "Clockwork status" | ||
task :status do | ||
on roles(:app) do | ||
within release_path do | ||
with rails_env: fetch(:rails_env) do | ||
execute :bundle, :exec, :clockworkd, "-c #{fetch(:clockwork_file)} --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} --log status" | ||
end | ||
end | ||
end | ||
end | ||
|
||
desc "Start clockwork" | ||
task :start do | ||
on roles(:app) do | ||
within release_path do | ||
with rails_env: fetch(:rails_env) do | ||
execute :bundle, :exec, :clockworkd, "-c #{fetch(:clockwork_file)} --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} --log start" | ||
end | ||
end | ||
end | ||
end | ||
|
||
desc "Restart clockwork" | ||
task :restart do | ||
on roles(:app) do | ||
within release_path do | ||
with rails_env: fetch(:rails_env) do | ||
execute :bundle, :exec, :clockworkd, "-c #{fetch(:clockwork_file)} --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} --log restart" | ||
end | ||
end | ||
end | ||
end | ||
|
||
def cw_log_dir | ||
"#{shared_path}/log" | ||
end | ||
def cw_pid_dir | ||
"#{shared_path}/tmp/pids" | ||
end | ||
|
||
def rails_env | ||
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : '' | ||
end | ||
|
||
task :add_default_hooks do | ||
after 'deploy:stop', 'clockwork:stop' | ||
after 'deploy:start', 'clockwork:start' | ||
after 'deploy:restart', 'clockwork:restart' | ||
end | ||
end |