amqp-daemon-kit 0.1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Configuration.txt +110 -0
- data/Deployment.txt +113 -0
- data/History.txt +131 -0
- data/Logging.txt +96 -0
- data/PostInstall.txt +6 -0
- data/README.rdoc +132 -0
- data/Rakefile +29 -0
- data/RuoteParticipants.txt +113 -0
- data/TODO.txt +27 -0
- data/bin/daemon-kit +18 -0
- data/config/website.yml +2 -0
- data/daemon-kit.gemspec +265 -0
- data/lib/daemon_kit.rb +60 -0
- data/lib/daemon_kit/abstract_logger.rb +249 -0
- data/lib/daemon_kit/application.rb +230 -0
- data/lib/daemon_kit/arguments.rb +165 -0
- data/lib/daemon_kit/commands/console.rb +38 -0
- data/lib/daemon_kit/commands/destroy.rb +10 -0
- data/lib/daemon_kit/commands/generate.rb +10 -0
- data/lib/daemon_kit/config.rb +113 -0
- data/lib/daemon_kit/console_daemon.rb +2 -0
- data/lib/daemon_kit/core_ext.rb +1 -0
- data/lib/daemon_kit/core_ext/configurable.rb +96 -0
- data/lib/daemon_kit/core_ext/string.rb +22 -0
- data/lib/daemon_kit/cron.rb +67 -0
- data/lib/daemon_kit/cucumber/world.rb +38 -0
- data/lib/daemon_kit/deployment/capistrano.rb +516 -0
- data/lib/daemon_kit/dk_amqp.rb +39 -0
- data/lib/daemon_kit/em.rb +43 -0
- data/lib/daemon_kit/error_handlers/base.rb +32 -0
- data/lib/daemon_kit/error_handlers/hoptoad.rb +180 -0
- data/lib/daemon_kit/exceptions.rb +15 -0
- data/lib/daemon_kit/generators.rb +67 -0
- data/lib/daemon_kit/generators/base.rb +60 -0
- data/lib/daemon_kit/initializer.rb +449 -0
- data/lib/daemon_kit/jabber.rb +171 -0
- data/lib/daemon_kit/nanite.rb +7 -0
- data/lib/daemon_kit/nanite/agent.rb +77 -0
- data/lib/daemon_kit/pid_file.rb +61 -0
- data/lib/daemon_kit/ruote_participants.rb +125 -0
- data/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
- data/lib/daemon_kit/ruote_workitem.rb +187 -0
- data/lib/daemon_kit/safety.rb +84 -0
- data/lib/daemon_kit/tasks.rb +2 -0
- data/lib/daemon_kit/tasks/environment.rake +11 -0
- data/lib/daemon_kit/tasks/framework.rake +123 -0
- data/lib/daemon_kit/tasks/god.rake +62 -0
- data/lib/daemon_kit/tasks/log.rake +8 -0
- data/lib/daemon_kit/tasks/monit.rake +29 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/CHANGELOG.rdoc +89 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/LICENSE +20 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/README.rdoc +297 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/Thorfile +69 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor.rb +244 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions.rb +296 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/create_file.rb +103 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/directory.rb +91 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/empty_directory.rb +134 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/file_manipulation.rb +223 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/inject_into_file.rb +104 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/base.rb +540 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/error.rb +30 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/group.rb +271 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/invocation.rb +180 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser.rb +4 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/argument.rb +67 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/arguments.rb +150 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/option.rb +128 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/options.rb +169 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/rake_compat.rb +66 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/runner.rb +314 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell.rb +83 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell/basic.rb +239 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell/color.rb +108 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/task.rb +102 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/util.rb +224 -0
- data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/version.rb +3 -0
- data/lib/daemon_kit/xmpp.rb +100 -0
- data/lib/generators/daemon_kit/amqp/USAGE +5 -0
- data/lib/generators/daemon_kit/amqp/amqp_generator.rb +24 -0
- data/lib/generators/daemon_kit/amqp/templates/config/amqp.yml +28 -0
- data/lib/generators/daemon_kit/amqp/templates/config/pre-daemonize/amqp.rb +7 -0
- data/lib/generators/daemon_kit/amqp/templates/libexec/%app_name%-daemon.rb +37 -0
- data/lib/generators/daemon_kit/app/USAGE +7 -0
- data/lib/generators/daemon_kit/app/app_generator.rb +140 -0
- data/lib/generators/daemon_kit/app/templates/Gemfile +12 -0
- data/lib/generators/daemon_kit/app/templates/README.tt +58 -0
- data/lib/generators/daemon_kit/app/templates/Rakefile +6 -0
- data/lib/generators/daemon_kit/app/templates/bin/daemon.tt +7 -0
- data/lib/generators/daemon_kit/app/templates/config/arguments.rb +12 -0
- data/lib/generators/daemon_kit/app/templates/config/boot.rb +70 -0
- data/lib/generators/daemon_kit/app/templates/config/environment.rb.tt +26 -0
- data/lib/generators/daemon_kit/app/templates/config/environments/development.rb +2 -0
- data/lib/generators/daemon_kit/app/templates/config/environments/production.rb +5 -0
- data/lib/generators/daemon_kit/app/templates/config/environments/test.rb +2 -0
- data/lib/generators/daemon_kit/app/templates/config/post-daemonize/readme +5 -0
- data/lib/generators/daemon_kit/app/templates/config/pre-daemonize/readme +12 -0
- data/lib/generators/daemon_kit/app/templates/lib/%app_name%.rb +2 -0
- data/lib/generators/daemon_kit/app/templates/libexec/%app_name%-daemon.rb +18 -0
- data/lib/generators/daemon_kit/app/templates/script/console +3 -0
- data/lib/generators/daemon_kit/app/templates/script/destroy +3 -0
- data/lib/generators/daemon_kit/app/templates/script/generate +3 -0
- data/lib/generators/daemon_kit/capistrano/capistrano_generator.rb +26 -0
- data/lib/generators/daemon_kit/capistrano/templates/Capfile +10 -0
- data/lib/generators/daemon_kit/capistrano/templates/USAGE +10 -0
- data/lib/generators/daemon_kit/capistrano/templates/config/deploy.rb.tt +67 -0
- data/lib/generators/daemon_kit/capistrano/templates/config/deploy/logrotate.erb +13 -0
- data/lib/generators/daemon_kit/capistrano/templates/config/deploy/production.rb.tt +6 -0
- data/lib/generators/daemon_kit/capistrano/templates/config/deploy/staging.rb.tt +6 -0
- data/lib/generators/daemon_kit/capistrano/templates/config/environments/staging.rb +0 -0
- data/lib/generators/daemon_kit/cron/USAGE +5 -0
- data/lib/generators/daemon_kit/cron/cron_generator.rb +24 -0
- data/lib/generators/daemon_kit/cron/templates/config/pre-daemonize/cron.rb +11 -0
- data/lib/generators/daemon_kit/cron/templates/libexec/%app_name%-daemon.rb +48 -0
- data/lib/generators/daemon_kit/cucumber/USAGE +11 -0
- data/lib/generators/daemon_kit/cucumber/cucumber_generator.rb +45 -0
- data/lib/generators/daemon_kit/cucumber/templates/config/environments/cucumber.rb +2 -0
- data/lib/generators/daemon_kit/cucumber/templates/features/step_definitions/.empty_directory +0 -0
- data/lib/generators/daemon_kit/cucumber/templates/features/support/env.rb +7 -0
- data/lib/generators/daemon_kit/cucumber/templates/script/cucumber +7 -0
- data/lib/generators/daemon_kit/cucumber/templates/tasks/cucumber.rake +13 -0
- data/lib/generators/daemon_kit/nanite_agent/USAGE +5 -0
- data/lib/generators/daemon_kit/nanite_agent/nanite_agent_generator.rb +29 -0
- data/lib/generators/daemon_kit/nanite_agent/templates/config/nanite.yml +35 -0
- data/lib/generators/daemon_kit/nanite_agent/templates/config/pre-daemonize/nanite_agent.rb +6 -0
- data/lib/generators/daemon_kit/nanite_agent/templates/lib/actors/sample.rb +11 -0
- data/lib/generators/daemon_kit/nanite_agent/templates/libexec/%app_name%-daemon.rb +31 -0
- data/lib/generators/daemon_kit/rspec/USAGE +5 -0
- data/lib/generators/daemon_kit/rspec/rspec_generator.rb +20 -0
- data/lib/generators/daemon_kit/rspec/templates/spec/%app_name%_spec.rb +11 -0
- data/lib/generators/daemon_kit/rspec/templates/spec/spec.opts +1 -0
- data/lib/generators/daemon_kit/rspec/templates/spec/spec_helper.rb +23 -0
- data/lib/generators/daemon_kit/rspec/templates/tasks/rspec.rake +21 -0
- data/lib/generators/daemon_kit/ruote/USAGE +5 -0
- data/lib/generators/daemon_kit/ruote/ruote_generator.rb +29 -0
- data/lib/generators/daemon_kit/ruote/templates/config/amqp.yml +30 -0
- data/lib/generators/daemon_kit/ruote/templates/config/pre-daemonize/ruote.rb +13 -0
- data/lib/generators/daemon_kit/ruote/templates/config/ruote.yml +23 -0
- data/lib/generators/daemon_kit/ruote/templates/lib/%app_name%.rb +4 -0
- data/lib/generators/daemon_kit/ruote/templates/lib/sample.rb +26 -0
- data/lib/generators/daemon_kit/ruote/templates/libexec/%app_name%-daemon.rb +33 -0
- data/lib/generators/daemon_kit/test_unit/USAGE +5 -0
- data/lib/generators/daemon_kit/test_unit/templates/tasks/test_unit.rake +7 -0
- data/lib/generators/daemon_kit/test_unit/templates/test/%app_name%_test.rb.tt +9 -0
- data/lib/generators/daemon_kit/test_unit/templates/test/test_helper.rb +6 -0
- data/lib/generators/daemon_kit/test_unit/test_unit_generator.rb +20 -0
- data/lib/generators/daemon_kit/xmpp/templates/config/pre-daemonize/xmpp.rb +6 -0
- data/lib/generators/daemon_kit/xmpp/templates/config/xmpp.yml +29 -0
- data/lib/generators/daemon_kit/xmpp/templates/libexec/%app_name%-daemon.rb +27 -0
- data/lib/generators/daemon_kit/xmpp/xmpp_generator.rb +24 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +71 -0
- data/spec/abstract_logger_spec.rb +126 -0
- data/spec/argument_spec.rb +70 -0
- data/spec/config_spec.rb +83 -0
- data/spec/configurable_spec.rb +56 -0
- data/spec/daemon_kit_spec.rb +7 -0
- data/spec/error_handlers_spec.rb +23 -0
- data/spec/fixtures/env.yml +15 -0
- data/spec/fixtures/noenv.yml +4 -0
- data/spec/initializer_spec.rb +26 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +27 -0
- data/tasks/cucumber.rake +13 -0
- data/tasks/rspec.rake +20 -0
- data/tasks/tests.rake +6 -0
- data/templates/god/god.erb +69 -0
- data/templates/monit/monit.erb +14 -0
- data/test/test_amqp_generator.rb +48 -0
- data/test/test_cron_generator.rb +45 -0
- data/test/test_daemon-kit_generator.rb +84 -0
- data/test/test_daemon_kit_config.rb +28 -0
- data/test/test_deploy_capistrano_generator.rb +48 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +7 -0
- data/test/test_nanite_agent_generator.rb +49 -0
- data/test/test_ruote_generator.rb +51 -0
- data/test/test_test_unit_generator.rb +46 -0
- metadata +302 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
# If you need to 'vendor your gems' for deploying your daemons, bundler is a
|
2
|
+
# great option. Update this Gemfile with any additional dependencies and run
|
3
|
+
# 'bundle install' to get them all installed. Daemon-kit's capistrano
|
4
|
+
# deployment will ensure that the bundle required by your daemon is properly
|
5
|
+
# installed.
|
6
|
+
|
7
|
+
source :gemcutter
|
8
|
+
|
9
|
+
# daemon-kit
|
10
|
+
gem 'daemon-kit'
|
11
|
+
|
12
|
+
# For more information on bundler, please visit http://gembundler.com
|
@@ -0,0 +1,58 @@
|
|
1
|
+
daemon-kit README
|
2
|
+
================
|
3
|
+
|
4
|
+
daemon-kit has generated a skeleton Ruby daemon for you to build on. Please read
|
5
|
+
through this file to ensure you get going quickly.
|
6
|
+
|
7
|
+
Directories
|
8
|
+
===========
|
9
|
+
|
10
|
+
bin/
|
11
|
+
<%= app_name %> - Stub executable to control your daemon with
|
12
|
+
|
13
|
+
config/
|
14
|
+
Environment configuration files
|
15
|
+
|
16
|
+
lib/
|
17
|
+
Place for your libraries
|
18
|
+
|
19
|
+
libexec/
|
20
|
+
<%= app_name %>.rb - Your daemon code
|
21
|
+
|
22
|
+
log/
|
23
|
+
Log files based on the environment name
|
24
|
+
|
25
|
+
spec/
|
26
|
+
rspec's home
|
27
|
+
|
28
|
+
tasks/
|
29
|
+
Place for rake tasks
|
30
|
+
|
31
|
+
vendor/
|
32
|
+
Place for unpacked gems and DaemonKit
|
33
|
+
|
34
|
+
tmp/
|
35
|
+
Scratch folder
|
36
|
+
|
37
|
+
|
38
|
+
Logging
|
39
|
+
=======
|
40
|
+
|
41
|
+
One of the biggest issues with writing daemons are getting insight into what your
|
42
|
+
daemons are doing. Logging with daemon-kit is simplified as DaemonKit creates log
|
43
|
+
files per environment in log.
|
44
|
+
|
45
|
+
On all environments except production the log level is set to DEBUG, but you can
|
46
|
+
toggle the log level by sending the running daemon SIGUSR1 and SIGUSR2 signals.
|
47
|
+
SIGUSR1 will toggle between DEBUG and INFO levels, SIGUSR2 will blatantly set the
|
48
|
+
level to DEBUG.
|
49
|
+
|
50
|
+
Bundler
|
51
|
+
=======
|
52
|
+
|
53
|
+
daemon-kit uses bundler to ease the nightmare of dependency loading in Ruby
|
54
|
+
projects. daemon-kit and its generators all create/update the Gemfile in the
|
55
|
+
root of the daemon. You can satisfy the project's dependencies by running
|
56
|
+
`bundle install` from within the project root.
|
57
|
+
|
58
|
+
For more information on bundler, please see http://github.com/carlhuda/bundler
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Argument handling for your daemon is configured here.
|
2
|
+
#
|
3
|
+
# You have access to two variables when this file is
|
4
|
+
# parsed. The first is +opts+, which is the object yielded from
|
5
|
+
# +OptionParser.new+, the second is +@options+ which is a standard
|
6
|
+
# Ruby hash that is later accessible through
|
7
|
+
# DaemonKit.arguments.options and can be used in your daemon process.
|
8
|
+
|
9
|
+
# Here is an example:
|
10
|
+
# opts.on('-f', '--foo FOO', 'Set foo') do |foo|
|
11
|
+
# @options[:foo] = foo
|
12
|
+
# end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your daemon in config/environment.rb
|
3
|
+
|
4
|
+
DAEMON_ROOT = "#{File.expand_path(File.dirname(__FILE__))}/.." unless defined?( DAEMON_ROOT )
|
5
|
+
|
6
|
+
# Use Bundler (preferred)
|
7
|
+
begin
|
8
|
+
require File.expand_path('../../.bundle/environment', __FILE__)
|
9
|
+
rescue LoadError
|
10
|
+
require 'rubygems'
|
11
|
+
require 'bundler'
|
12
|
+
Bundler.setup
|
13
|
+
end
|
14
|
+
|
15
|
+
module DaemonKit
|
16
|
+
class << self
|
17
|
+
def boot!
|
18
|
+
unless booted?
|
19
|
+
pick_boot.run
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def booted?
|
24
|
+
defined? DaemonKit::Initializer
|
25
|
+
end
|
26
|
+
|
27
|
+
def pick_boot
|
28
|
+
(vendor_kit? ? VendorBoot : GemBoot).new
|
29
|
+
end
|
30
|
+
|
31
|
+
def vendor_kit?
|
32
|
+
File.exists?( "#{DAEMON_ROOT}/vendor/daemon-kit" )
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
DaemonKit::Initializer.run
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class VendorBoot < Boot
|
44
|
+
def load_initializer
|
45
|
+
require "#{DAEMON_ROOT}/vendor/daemon-kit/lib/daemon_kit/initializer"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class GemBoot < Boot
|
50
|
+
def load_initializer
|
51
|
+
begin
|
52
|
+
require 'rubygems' unless defined?( ::Gem )
|
53
|
+
gem 'daemon-kit'
|
54
|
+
require 'daemon_kit/initializer'
|
55
|
+
rescue ::Gem::LoadError => e
|
56
|
+
msg = <<EOF
|
57
|
+
|
58
|
+
You are missing the daemon-kit gem. Please install the following gem:
|
59
|
+
|
60
|
+
sudo gem install daemon-kit
|
61
|
+
|
62
|
+
EOF
|
63
|
+
$stderr.puts msg
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
DaemonKit.boot!
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Be sure to restart your daemon when you modify this file
|
2
|
+
|
3
|
+
# Uncomment below to force your daemon into production mode
|
4
|
+
#ENV['DAEMON_ENV'] ||= 'production'
|
5
|
+
|
6
|
+
# Boot up
|
7
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
8
|
+
|
9
|
+
# Auto-require default libraries and those for the current Rails environment.
|
10
|
+
Bundler.require :default, DaemonKit.env
|
11
|
+
|
12
|
+
DaemonKit::Initializer.run do |config|
|
13
|
+
|
14
|
+
# The name of the daemon as reported by process monitoring tools
|
15
|
+
config.daemon_name = '<%= app_name %>'
|
16
|
+
|
17
|
+
# Force the daemon to be killed after X seconds from asking it to
|
18
|
+
# config.force_kill_wait = 30
|
19
|
+
|
20
|
+
# Log backraces when a thread/daemon dies (Recommended)
|
21
|
+
# config.backtraces = true
|
22
|
+
|
23
|
+
# Configure the safety net (see DaemonKit::Safety)
|
24
|
+
# config.safety_net.handler = :hoptoad
|
25
|
+
# config.safety_net.hoptoad.api_key = ''
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# You can place files in here to be loaded before the code is daemonized.
|
2
|
+
#
|
3
|
+
# DaemonKit looks for a file named '<config.daemon_name>.rb' and loads
|
4
|
+
# that file first, and inside a DaemonKit::Initializer block. The
|
5
|
+
# remaning files then simply required into the running process.
|
6
|
+
#
|
7
|
+
# These files are mostly useful for operations that should fail blatantly
|
8
|
+
# before daemonizing, like loading gems.
|
9
|
+
#
|
10
|
+
# Be careful not to open any form of IO in here and expecting it to be
|
11
|
+
# open inside the running daemon since all IO instances are closed when
|
12
|
+
# daemonizing (including STDIN, STDOUT & STDERR).
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Change this file to be a wrapper around your daemon code.
|
2
|
+
|
3
|
+
# Do your post daemonization configuration here
|
4
|
+
# At minimum you need just the first line (without the block), or a lot
|
5
|
+
# of strange things might start happening...
|
6
|
+
DaemonKit::Application.running! do |config|
|
7
|
+
# Trap signals with blocks or procs
|
8
|
+
# config.trap( 'INT' ) do
|
9
|
+
# # do something clever
|
10
|
+
# end
|
11
|
+
# config.trap( 'TERM', Proc.new { puts 'Going down' } )
|
12
|
+
end
|
13
|
+
|
14
|
+
# Sample loop to show process
|
15
|
+
loop do
|
16
|
+
DaemonKit.logger.info "I'm running"
|
17
|
+
sleep 60
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module DaemonKit
|
2
|
+
module Generators
|
3
|
+
class CapistranoGenerator < Base
|
4
|
+
|
5
|
+
def update_gemfile
|
6
|
+
append_file 'Gemfile', "gem 'capistrano'\n"
|
7
|
+
append_file 'Gemfile', "gem 'capistrano-ext'\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_capfile
|
11
|
+
copy_file 'Capfile'
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_config
|
15
|
+
directory 'config'
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def self.source_root
|
21
|
+
File.expand_path( File.join( File.dirname(__FILE__), 'templates') )
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
unless respond_to?(:namespace) # cap2 differentiator
|
2
|
+
$stderr.puts "Requires capistrano version 2"
|
3
|
+
exit 1
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'config/boot'
|
7
|
+
load DaemonKit.framework_root + '/lib/daemon_kit/deployment/capistrano.rb'
|
8
|
+
|
9
|
+
Dir['config/deploy/recipes/*.rb'].each { |plugin| load(plugin) }
|
10
|
+
load 'config/deploy.rb'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
Capistrano deployment configuration generator completed
|
3
|
+
|
4
|
+
Usage:
|
5
|
+
Review the configuration files in config/deploy.rb and
|
6
|
+
config/deploy/*.rb
|
7
|
+
|
8
|
+
Once you're happy with the configurations, you can review
|
9
|
+
a list of available capistrano commands by running `cap -T'
|
10
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Modified capistrano recipe, based on the standard 'deploy' recipe
|
2
|
+
# provided by capistrano but without the Rails-specific dependencies
|
3
|
+
|
4
|
+
set :stages, %w(staging production)
|
5
|
+
set :default_stage, "staging"
|
6
|
+
require "capistrano/ext/multistage"
|
7
|
+
|
8
|
+
# Set some globals
|
9
|
+
default_run_options[:pty] = true
|
10
|
+
set :application, "<%= app_name %>"
|
11
|
+
|
12
|
+
# Deployment
|
13
|
+
set :deploy_to, "/svc/#{application}"
|
14
|
+
#set :user, 'someone'
|
15
|
+
|
16
|
+
# Get repo configuration
|
17
|
+
set :repository, "git@github.com:yourname/#{application}.git"
|
18
|
+
set :scm, "git"
|
19
|
+
set :branch, "master"
|
20
|
+
set :deploy_via, :remote_cache
|
21
|
+
set :git_enable_submodules, 1
|
22
|
+
|
23
|
+
# No sudo
|
24
|
+
set :use_sudo, false
|
25
|
+
|
26
|
+
# File list in the config_files setting will be copied from the
|
27
|
+
# 'deploy_to' directory into config, overwriting files from the repo
|
28
|
+
# with the same name
|
29
|
+
set :config_files, %w{}
|
30
|
+
|
31
|
+
# List any work directories here that you need persisted between
|
32
|
+
# deployments. They are created in 'deploy_to'/shared and symlinked
|
33
|
+
# into the root directory of the deployment.
|
34
|
+
set :shared_children, %w{log tmp}
|
35
|
+
|
36
|
+
# Record our dependencies
|
37
|
+
unless File.directory?( "#{DaemonKit.root}/vendor/daemon_kit" )
|
38
|
+
depend :remote, :gem, "daemon-kit", ">=#{DaemonKit::VERSION}"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Hook into capistrano's events
|
42
|
+
before "deploy:update_code", "deploy:check"
|
43
|
+
|
44
|
+
# Setup log rotation support with every deploy (safe)
|
45
|
+
#after 'deploy:symlink', 'deploy:logrotate'
|
46
|
+
|
47
|
+
# Create some tasks related to deployment
|
48
|
+
namespace :deploy do
|
49
|
+
|
50
|
+
desc "Get the current revision of the deployed code"
|
51
|
+
task :get_current_version do
|
52
|
+
run "cat #{current_path}/REVISION" do |ch, stream, out|
|
53
|
+
puts "Current revision: " + out.chomp
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Install log rotation script on server"
|
58
|
+
task :logrotate do
|
59
|
+
require 'erb'
|
60
|
+
upload_path = "#{shared_path}/system/logrotate"
|
61
|
+
template = File.read("config/deploy/logrotate.erb")
|
62
|
+
file = ERB.new(template).result(binding)
|
63
|
+
put file, upload_path, :mode => 0644
|
64
|
+
run "if [ -e /etc/logrotate.d ]; then sudo cp #{shared_path}/system/logrotate /etc/logrotate.d/#{name}; fi"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DaemonKit
|
2
|
+
module Generators
|
3
|
+
class CronGenerator < Base
|
4
|
+
|
5
|
+
def update_gemfile
|
6
|
+
append_file 'Gemfile', "gem 'rufus-scheduler', '>= 2.0.3'\n"
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_initializers
|
10
|
+
directory 'config'
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_daemon
|
14
|
+
directory 'libexec'
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def self.source_root
|
20
|
+
File.expand_path( File.join( File.dirname(__FILE__), 'templates') )
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|