Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Jan 29, 2013
0 parents commit e348e6a
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "http://www.rubygems.org"

gemspec
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
LICENSE

The MIT License

Copyright (c) 2012 Nadarei, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# mina-sidekiq

mina-sidekiq is a gem that adds tasks to aid in the deployment of [Sidekiq] (http://mperham.github.com/sidekiq/)
using [Mina] (http://nadarei.co/mina).

# Getting Start

## Installation

gem install mina-sidekiq

## Example

require 'mina-sidekiq'
...

task :deploy => :enviroment do
deploy do
# stop accepting new workers
invoke :'sidekiq:quiet'
invoke :'git:clone'
...

to :launch do
...
invoke :'sidekiq:restart'
end
end
end

## Available Tasks

* sidekiq:stop
* sidekiq:start
* sidekiq:restart
* sidekiq:quiet

## Available Options

* sidekiq: Sets the path to sidekiq.
* sidekiqctl: Sets the path to sidekiqctl.
* sidekiq\_timeout: Sets a upper limit of time a worker is allowed to finish, before it is killed.
* sidekiq\_log: Sets the path to the log file of sidekiq
* sidekiq\_pid: Sets the path to the pid file of a sidekiq worker

## Copyright

Copyright (c) 2013 Jörg Thalheim http://higgsboson.tk/joerg
See LICENSE for further details.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
1 change: 1 addition & 0 deletions lib/mina-sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "mina-sidekiq/sidekiq"
88 changes: 88 additions & 0 deletions lib/mina-sidekiq/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# # Modules: Sidekiq
# Adds settings and tasks for managing Sidekiq workers.
#
# ## Usage example
# require 'mina/sidekiq'
# ...
#
# task :deploy => :enviroment do
# deploy do
# invoke :'sidekiq:quiet'
# invoke :'git:clone'
# ...
#
# to :launch do
# ...
# invoke :'sidekiq:restart'
# end
# end
# end

require 'mina/bundler'
require 'mina/rails'

# ## Settings
# Any and all of these settings can be overriden in your `deploy.rb`.

# ### sidekiq
# Sets the path to sidekiq.
set_default :sidekiq, lambda { "#{bundle_bin} exec sidekiq" }

# ### sidekiqctl
# Sets the path to sidekiqctl.
set_default :sidekiqctl, lambda { "#{bundle_prefix} sidekiqctl" }

# ### sidekiq_timeout
# Sets a upper limit of time a worker is allowed to finish, before it is killed.
set_default :sidekiq_timeout, 10

# ### sidekiq_config
# Sets the path to the configuration file of sidekiq
set_default :sidekiq_config, "./config/sidekiq.yml"

# ### sidekiq_log
# Sets the path to the log file of sidekiq
#
# To disable logging set it to "/dev/null"
set_default :sidekiq_log, "./log/sidekiq.log"

# ### sidekiq_pid
# Sets the path to the pid file of a sidekiq worker
set_default :sidekiq_pid, lambda { "#{deploy_to}/#{shared_path}/pids/sidekiq.pid" }

# ## Control Tasks
namespace :sidekiq do
# ### sidekiq:quiet
desc "Quiet sidekiq (stop accepting new work)"
task :quiet do
queue %{ if [ -f #{sidekiq_pid} ]; then
echo "-----> Quiet sidekiq (stop accepting new work)"
#{echo_cmd %{(cd #{deploy_to}/#{current_path} && #{sidekiqctl} quiet #{sidekiq_pid})} }
fi }
end

# ### sidekiq:stop
desc "Stop sidekiq"
task :stop do
queue %[ if [ -f #{sidekiq_pid} ]; then
echo "-----> Stop sidekiq"
#{echo_cmd %[(cd #{deploy_to}/#{current_path} && #{sidekiqctl} stop #{sidekiq_pid} #{sidekiq_timeout})]}
fi ]
end

# ### sidekiq:start
desc "Start sidekiq"
task :start do
queue %{
echo "-----> Start sidekiq"
#{echo_cmd %[(cd #{deploy_to}/#{current_path}; nohup #{sidekiq} -e #{rails_env} -C #{sidekiq_config} -P #{sidekiq_pid} >> #{sidekiq_log} 2>&1 </dev/null &) ] }
}
end

# ### sidekiq:restart
desc "Restart sidekiq"
task :restart do
invoke :'sidekiq:stop'
invoke :'sidekiq:start'
end
end
18 changes: 18 additions & 0 deletions mina-sidekiq.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = "mina-sidekiq"
s.version = File.read('VERSION')
s.authors = ["Joerg Thalheim"]
s.email = ["joerg@higgsboson.tk"]
s.homepage = "http://github.com/Mic92/mina-sidekiq"
s.summary = "Tasks to deploy Sidekiq with mina."
s.description = "Tasks to deploy Sidekiq with mina."

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_runtime_dependency "mina"
end

0 comments on commit e348e6a

Please sign in to comment.