kennethkalmer-daemon-kit 0.1.6 → 0.1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Configuration.txt +58 -0
- data/History.txt +16 -0
- data/Manifest.txt +29 -2
- data/PostInstall.txt +1 -1
- data/{README.textile → README.rdoc} +31 -19
- data/Rakefile +2 -4
- data/TODO.txt +6 -5
- data/app_generators/daemon_kit/daemon_kit_generator.rb +29 -0
- data/app_generators/daemon_kit/templates/Rakefile +3 -1
- data/app_generators/daemon_kit/templates/config/arguments.rb +12 -0
- data/app_generators/daemon_kit/templates/config/boot.rb +2 -2
- data/app_generators/daemon_kit/templates/script/console +3 -0
- data/app_generators/daemon_kit/templates/script/destroy +14 -0
- data/app_generators/daemon_kit/templates/script/generate +14 -0
- data/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +35 -0
- data/daemon_generators/deploy_capistrano/templates/Capfile +10 -0
- data/daemon_generators/deploy_capistrano/templates/USAGE +10 -0
- data/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +6 -0
- data/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +6 -0
- data/daemon_generators/deploy_capistrano/templates/config/deploy.rb +51 -0
- data/daemon_generators/deploy_capistrano/templates/config/environments/staging.rb +0 -0
- data/lib/daemon_kit/application.rb +135 -11
- data/lib/daemon_kit/arguments.rb +151 -0
- data/lib/daemon_kit/commands/console.rb +38 -0
- data/lib/daemon_kit/config.rb +1 -0
- data/lib/daemon_kit/console_daemon.rb +2 -0
- data/lib/daemon_kit/core_ext/string.rb +22 -0
- data/lib/daemon_kit/core_ext.rb +1 -0
- data/lib/daemon_kit/deployment/capistrano.rb +485 -0
- data/lib/daemon_kit/initializer.rb +87 -25
- data/lib/daemon_kit/pid_file.rb +61 -0
- data/lib/daemon_kit/tasks/environment.rake +5 -4
- data/lib/daemon_kit/tasks/framework.rake +15 -1
- data/lib/daemon_kit/tasks/god.rake +62 -0
- data/lib/daemon_kit/tasks/monit.rake +29 -0
- data/lib/daemon_kit.rb +11 -5
- data/rubygems_generators/install_rspec/templates/spec/spec_helper.rb +1 -1
- data/spec/argument_spec.rb +51 -0
- data/spec/config_spec.rb +77 -0
- data/spec/daemon_kit_spec.rb +2 -2
- data/spec/fixtures/env.yml +15 -0
- data/spec/fixtures/noenv.yml +4 -0
- data/spec/initializer_spec.rb +4 -3
- data/spec/spec_helper.rb +8 -11
- data/templates/god/god.erb +69 -0
- data/templates/monit/monit.erb +14 -0
- data/test/test_daemon-kit_generator.rb +15 -1
- data/test/test_deploy_capistrano_generator.rb +48 -0
- metadata +41 -21
- data/lib/daemon_kit/patches/force_kill_wait.rb +0 -120
data/Configuration.txt
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= Configuring your daemon
|
2
|
+
|
3
|
+
daemon-kit provides a multitude of ways to configure your daemon, this document
|
4
|
+
will outline the different options available to you.
|
5
|
+
|
6
|
+
== Configuration files and #DaemonKit::Config
|
7
|
+
|
8
|
+
#DaemonKit::Config gives you easy access to any YAML configuration
|
9
|
+
files you have in your <em>config</em> directory.
|
10
|
+
|
11
|
+
You can access the configuration files like this:
|
12
|
+
|
13
|
+
config = DaemonKit::Config.load('sample')
|
14
|
+
|
15
|
+
The above snippet relies on the presence of a <em>config/sample.yml</em> file.
|
16
|
+
|
17
|
+
#DaemonKit::Config is environment aware, so configuration files are
|
18
|
+
parsed for a top-level key that is the same as the value of
|
19
|
+
<em>DAEMON_ENV</em>, and if present is loaded into the object as the
|
20
|
+
configuration data. If the key is not present, the whole YAML
|
21
|
+
document is exposed as configuration data.
|
22
|
+
|
23
|
+
== Command line arguments
|
24
|
+
|
25
|
+
The most flexible way to configure your daemon is through command line
|
26
|
+
arguments, or switches.
|
27
|
+
|
28
|
+
DaemonKit includes a couple of its own arguments that can be used:
|
29
|
+
|
30
|
+
-e ENV (or --env ENV) to set the daemon environment
|
31
|
+
--pid /path/to/pidfile to set the path to a pidfile
|
32
|
+
-v shows the DaemonKit version
|
33
|
+
-h shows a useful help message
|
34
|
+
|
35
|
+
=== Custom arguments
|
36
|
+
|
37
|
+
It is possible for you to specify your own arguments as well, by
|
38
|
+
updating the <em>config/arguments.rb</em> file. This file is eval'd
|
39
|
+
inside #DaemonKit::Arguments and gives you access to the following two
|
40
|
+
variables:
|
41
|
+
|
42
|
+
* opts - Instance of OptionParser[http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html]
|
43
|
+
* @options - A standard Ruby hash that you can populate and access later
|
44
|
+
|
45
|
+
Your custom arguments can be accessed like this:
|
46
|
+
|
47
|
+
DaemonKit.arguments.options
|
48
|
+
|
49
|
+
=== Advanced Configuration
|
50
|
+
|
51
|
+
All the writable attributes of the default #DaemonKit::Configuration
|
52
|
+
instance call also be modified from the command line using the special
|
53
|
+
<em>--config</em> arguments:
|
54
|
+
|
55
|
+
--config force_kill_wait=30
|
56
|
+
|
57
|
+
This happens after <em>config/environment.rb</em> is processed, so all
|
58
|
+
command line arguments will overwrite those values.
|
data/History.txt
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
== 0.1.7.3 2009-05-31
|
2
|
+
|
3
|
+
* Removed dependency on daemons gem, now handled in house
|
4
|
+
* New argument management
|
5
|
+
* Some more docs
|
6
|
+
|
7
|
+
== 0.1.7.1 2009-05-28
|
8
|
+
|
9
|
+
* Fixed some minor issue with Capistrano support
|
10
|
+
* Added support for generating dog/monit configuration files via rake
|
11
|
+
* Initial implementation of ./script/* utilities
|
12
|
+
|
13
|
+
== 0.1.7 2009-05-26
|
14
|
+
|
15
|
+
* Capistrano deployment support
|
16
|
+
|
1
17
|
== 0.1.6 2009-05-13
|
2
18
|
|
3
19
|
* DaemonKit::Safety class to handle the trapping and logging of
|
data/Manifest.txt
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
Configuration.txt
|
1
2
|
History.txt
|
2
3
|
Manifest.txt
|
3
4
|
PostInstall.txt
|
4
|
-
README.
|
5
|
+
README.rdoc
|
5
6
|
Rakefile
|
6
7
|
TODO.txt
|
7
8
|
app_generators/daemon_kit/USAGE
|
@@ -9,6 +10,7 @@ app_generators/daemon_kit/daemon_kit_generator.rb
|
|
9
10
|
app_generators/daemon_kit/templates/README
|
10
11
|
app_generators/daemon_kit/templates/Rakefile
|
11
12
|
app_generators/daemon_kit/templates/bin/daemon.erb
|
13
|
+
app_generators/daemon_kit/templates/config/arguments.rb
|
12
14
|
app_generators/daemon_kit/templates/config/boot.rb
|
13
15
|
app_generators/daemon_kit/templates/config/environment.rb
|
14
16
|
app_generators/daemon_kit/templates/config/environments/development.rb
|
@@ -18,6 +20,9 @@ app_generators/daemon_kit/templates/config/post-daemonize/readme
|
|
18
20
|
app_generators/daemon_kit/templates/config/pre-daemonize/readme
|
19
21
|
app_generators/daemon_kit/templates/lib/daemon.rb
|
20
22
|
app_generators/daemon_kit/templates/libexec/daemon.erb
|
23
|
+
app_generators/daemon_kit/templates/script/console
|
24
|
+
app_generators/daemon_kit/templates/script/destroy
|
25
|
+
app_generators/daemon_kit/templates/script/generate
|
21
26
|
bin/daemon_kit
|
22
27
|
daemon_generators/amqp/USAGE
|
23
28
|
daemon_generators/amqp/amqp_generator.rb
|
@@ -28,6 +33,13 @@ daemon_generators/cron/USAGE
|
|
28
33
|
daemon_generators/cron/cron_generator.rb
|
29
34
|
daemon_generators/cron/templates/config/initializers/cron.rb
|
30
35
|
daemon_generators/cron/templates/libexec/daemon.rb
|
36
|
+
daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb
|
37
|
+
daemon_generators/deploy_capistrano/templates/Capfile
|
38
|
+
daemon_generators/deploy_capistrano/templates/USAGE
|
39
|
+
daemon_generators/deploy_capistrano/templates/config/deploy.rb
|
40
|
+
daemon_generators/deploy_capistrano/templates/config/deploy/production.rb
|
41
|
+
daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb
|
42
|
+
daemon_generators/deploy_capistrano/templates/config/environments/staging.rb
|
31
43
|
daemon_generators/jabber/USAGE
|
32
44
|
daemon_generators/jabber/jabber_generator.rb
|
33
45
|
daemon_generators/jabber/templates/config/initializers/jabber.rb
|
@@ -42,8 +54,14 @@ daemon_generators/nanite_agent/templates/libexec/daemon.rb
|
|
42
54
|
lib/daemon_kit.rb
|
43
55
|
lib/daemon_kit/amqp.rb
|
44
56
|
lib/daemon_kit/application.rb
|
57
|
+
lib/daemon_kit/arguments.rb
|
58
|
+
lib/daemon_kit/commands/console.rb
|
45
59
|
lib/daemon_kit/config.rb
|
60
|
+
lib/daemon_kit/console_daemon.rb
|
61
|
+
lib/daemon_kit/core_ext.rb
|
62
|
+
lib/daemon_kit/core_ext/string.rb
|
46
63
|
lib/daemon_kit/cron.rb
|
64
|
+
lib/daemon_kit/deployment/capistrano.rb
|
47
65
|
lib/daemon_kit/error_handlers/base.rb
|
48
66
|
lib/daemon_kit/error_handlers/hoptoad.rb
|
49
67
|
lib/daemon_kit/error_handlers/mail.rb
|
@@ -51,11 +69,13 @@ lib/daemon_kit/initializer.rb
|
|
51
69
|
lib/daemon_kit/jabber.rb
|
52
70
|
lib/daemon_kit/nanite.rb
|
53
71
|
lib/daemon_kit/nanite/agent.rb
|
54
|
-
lib/daemon_kit/
|
72
|
+
lib/daemon_kit/pid_file.rb
|
55
73
|
lib/daemon_kit/safety.rb
|
56
74
|
lib/daemon_kit/tasks.rb
|
57
75
|
lib/daemon_kit/tasks/environment.rake
|
58
76
|
lib/daemon_kit/tasks/framework.rake
|
77
|
+
lib/daemon_kit/tasks/god.rake
|
78
|
+
lib/daemon_kit/tasks/monit.rake
|
59
79
|
rubygems_generators/install_rspec/USAGE
|
60
80
|
rubygems_generators/install_rspec/install_rspec_generator.rb
|
61
81
|
rubygems_generators/install_rspec/templates/spec.rb
|
@@ -66,15 +86,22 @@ script/console
|
|
66
86
|
script/destroy
|
67
87
|
script/generate
|
68
88
|
script/txt2html
|
89
|
+
spec/argument_spec.rb
|
90
|
+
spec/config_spec.rb
|
69
91
|
spec/daemon_kit_spec.rb
|
92
|
+
spec/fixtures/env.yml
|
93
|
+
spec/fixtures/noenv.yml
|
70
94
|
spec/initializer_spec.rb
|
71
95
|
spec/spec.opts
|
72
96
|
spec/spec_helper.rb
|
73
97
|
tasks/rspec.rake
|
98
|
+
templates/god/god.erb
|
99
|
+
templates/monit/monit.erb
|
74
100
|
test/test_amqp_generator.rb
|
75
101
|
test/test_cron_generator.rb
|
76
102
|
test/test_daemon-kit_generator.rb
|
77
103
|
test/test_daemon_kit_config.rb
|
104
|
+
test/test_deploy_capistrano_generator.rb
|
78
105
|
test/test_generator_helper.rb
|
79
106
|
test/test_helper.rb
|
80
107
|
test/test_jabber_generator.rb
|
data/PostInstall.txt
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
= Daemon Kit
|
2
2
|
|
3
|
-
* http://
|
3
|
+
* http://kit.rubyforge.org/daemon-kit/rdoc/
|
4
|
+
* http://kit.rubyforge.org/daemon-kit (coming soon)
|
5
|
+
* http://groups.google.com/group/daemon-kit (daemon-kit@googlegroups.com)
|
6
|
+
* #daemon-kit on Freenode
|
4
7
|
|
5
|
-
|
8
|
+
== Description
|
6
9
|
|
7
10
|
Daemon Kit aims to simplify creating Ruby daemons by providing a sound application skeleton (through a generator), task specific generators (jabber bot, etc) and robust environment management code.
|
8
11
|
|
@@ -14,12 +17,13 @@ Supported generators:
|
|
14
17
|
* Evented and non-evented loops (coming soon)
|
15
18
|
* Queue poller (SQS, AMQP, etc) (coming soon)
|
16
19
|
|
17
|
-
|
20
|
+
== Features/Problems
|
18
21
|
|
19
22
|
* Build it
|
20
23
|
* Review TODO.txt
|
24
|
+
* Review Configuration.txt
|
21
25
|
|
22
|
-
|
26
|
+
== Synopsis
|
23
27
|
|
24
28
|
$ daemon-kit [/path/to/your/daemon] [options]
|
25
29
|
|
@@ -29,46 +33,54 @@ The above command generates a skeleton daemon environment for you to adapt.
|
|
29
33
|
|
30
34
|
Use the 'jabber' generator instead of the default one.
|
31
35
|
|
32
|
-
|
36
|
+
== Generators
|
33
37
|
|
34
38
|
Currently only two generators exist, a 'default' generator and a 'jabber' generator.
|
35
39
|
|
36
40
|
The default generator creates a simple daemon with an infinite loop inside that you can adapt.
|
37
41
|
|
38
|
-
|
42
|
+
=== Jabber Generator
|
39
43
|
|
40
44
|
The jabber generator creates a simple daemon that leverages the "xmpp4r-simple":http://xmpp4r-simple.rubyforge.org/ gem to process inbound messages. The daemon will manage the roster and other little tasks, leaving you to provide the hooks for processing messages, presence notifications and subscription request.
|
41
45
|
|
42
|
-
|
46
|
+
=== Cron Generator
|
43
47
|
|
44
48
|
The cron generator creates a simple daemon that leverages the "rufus-scheduler":http://github.com/jmettraux/rufus-scheduler gem to create a simple cron-lie daemon. Please be aware that this daemon could never be a replacement for the battle-tested "cron utility":http://www.gentoo.org/doc/en/cron-guide.xml shipped standard with most *nix distributions.
|
45
49
|
|
46
|
-
|
50
|
+
=== AMQP Consumer Generator
|
47
51
|
|
48
52
|
The AMQP generator creates a simple daemon that has all the stub code and configuration in place to help you write AMQP consumers quickly and effectively. The generated daemon relies on the presence of the "amqp":http://github.com/tmm1/amqp gem.
|
49
53
|
|
50
|
-
|
54
|
+
== Requirements
|
51
55
|
|
52
56
|
* Ruby 1.8.6
|
53
|
-
*
|
54
|
-
* rspec 1.1.11 (for writing/running your specs)
|
57
|
+
* rspec (for writing/running your specs)
|
55
58
|
|
56
|
-
|
59
|
+
== Generator Requirements
|
57
60
|
|
58
61
|
Depending on the generator you choose for your daemon, it might require additional gems to run.
|
59
62
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|amqp|"amqp":http://github.com/tmm1/amqp|
|
63
|
+
* jabber - xmpp4r-simple[http://xmpp4r-simple.rubyforge.org]
|
64
|
+
* cron - rufus-scheduler[http://github.com/jmettraux/rufus-scheduler]
|
65
|
+
* amqp - amqp[http://github.com/tmm1/amqp]
|
64
66
|
|
65
|
-
|
67
|
+
== Install
|
68
|
+
|
69
|
+
Currently recommended to stick to the git repo:
|
66
70
|
|
67
71
|
$ git clone git://github.com/kennethkalmer/daemon-kit.git
|
68
72
|
$ rake gem
|
69
73
|
$ gem install pkg/daemon-kit-X.X.X.gem
|
70
74
|
|
71
|
-
|
75
|
+
Development versions are available as gems from github:
|
76
|
+
|
77
|
+
$ gem install kennethkalmer-daemon-kit -s http://gems.github.com
|
78
|
+
|
79
|
+
Stable versions, when released are available directly from Rubyforge:
|
80
|
+
|
81
|
+
$ gem install daemon-kit
|
82
|
+
|
83
|
+
== License
|
72
84
|
|
73
85
|
(The MIT License)
|
74
86
|
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
3
2
|
require File.dirname(__FILE__) + '/lib/daemon_kit'
|
4
3
|
|
@@ -9,15 +8,14 @@ $hoe = Hoe.new('daemon-kit', DaemonKit::VERSION) do |p|
|
|
9
8
|
p.developer('Kenneth Kalmer', 'kenneth.kalmer@gmail.com')
|
10
9
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
11
10
|
p.post_install_message = IO.read( 'PostInstall.txt' ) # TODO remove if post-install message not required
|
12
|
-
p.rubyforge_name =
|
11
|
+
p.rubyforge_name = 'kit' # TODO this is default value
|
13
12
|
p.extra_deps = [
|
14
|
-
['daemons','>= 1.0.10'],
|
15
13
|
['rubigen', '>= 1.5.2']
|
16
14
|
]
|
17
15
|
p.extra_dev_deps = [
|
18
16
|
['newgem', ">= #{::Newgem::VERSION}"]
|
19
17
|
]
|
20
|
-
|
18
|
+
|
21
19
|
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
22
20
|
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
23
21
|
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
data/TODO.txt
CHANGED
@@ -3,22 +3,18 @@ DaemonKit TODO List
|
|
3
3
|
|
4
4
|
This is purely a drop in the bucket of what has to come...
|
5
5
|
|
6
|
-
* [DONE] Easy way to trap signals
|
7
6
|
* [IN PROGRESS] Error handling to the degree Rails does
|
8
7
|
* Easy configuration of an ORM of choice, including patching it if needed (ActiveRecord *cough*)
|
9
8
|
* Improved generators for creating skeleton daemons:
|
10
|
-
* [DONE] Jabber bot
|
11
9
|
* Evented jabber bot
|
12
10
|
* Empty periodic event loop
|
13
11
|
* Empty periodic loop (non-evented)
|
14
12
|
* Queue (SQS, AMQP, etc) pollers
|
15
13
|
* Rake tasks for generating:
|
16
|
-
* god configs
|
17
14
|
* Sys-V style init scripts
|
18
|
-
* Pre-built capistrano configs for easy deployment
|
19
15
|
* Support for dropping privileges
|
20
16
|
* Support for chroot'ing
|
21
|
-
* Improved and cleaned up logging
|
17
|
+
* Improved and cleaned up logging, support logrotating (via HUP)
|
22
18
|
* Plenty of docs, seriously a lot of docs
|
23
19
|
* Specs & features, tons of them too
|
24
20
|
* Integration tests for the specific daemons
|
@@ -29,4 +25,9 @@ This is purely a drop in the bucket of what has to come...
|
|
29
25
|
* Some activesupport-esque functions until activesupport 3.0 hits the streets
|
30
26
|
* DRY up the following:
|
31
27
|
* Loading configuration files for the daemons
|
28
|
+
* Altering process names (fully and temporary appending)
|
29
|
+
* bleak_house support
|
30
|
+
* Support for tweaking REE environment variables prior to launch (bash wrapper)
|
31
|
+
* Clustering support (run multiple workers out of same project)
|
32
|
+
|
32
33
|
* DON'T FORGET 1.9 SUPPORT
|
@@ -5,10 +5,13 @@ class DaemonKitGenerator < RubiGen::Base
|
|
5
5
|
|
6
6
|
VALID_GENERATORS = ['default', 'jabber', 'cron', 'amqp', 'nanite_agent']
|
7
7
|
|
8
|
+
DEPLOYERS = ['none', 'capistrano']
|
9
|
+
|
8
10
|
default_options :shebang => DEFAULT_SHEBANG, :author => nil
|
9
11
|
|
10
12
|
attr_reader :daemon_name
|
11
13
|
attr_reader :installer
|
14
|
+
attr_reader :deployer
|
12
15
|
|
13
16
|
def initialize(runtime_args, runtime_options = {})
|
14
17
|
super
|
@@ -26,6 +29,12 @@ class DaemonKitGenerator < RubiGen::Base
|
|
26
29
|
exit 1
|
27
30
|
end
|
28
31
|
|
32
|
+
unless DEPLOYERS.include?( deployer )
|
33
|
+
$stderr.puts "Invalid deployment mechanism: '#{deployer}'."
|
34
|
+
$stderr.puts "Valid deployers are: #{DEPLOYERS.join(', ')}"
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
29
38
|
script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
|
30
39
|
|
31
40
|
record do |m|
|
@@ -56,6 +65,7 @@ class DaemonKitGenerator < RubiGen::Base
|
|
56
65
|
|
57
66
|
# Config/Environment
|
58
67
|
m.directory "config"
|
68
|
+
m.file "config/arguments.rb", "config/arguments.rb"
|
59
69
|
m.file "config/boot.rb", "config/boot.rb"
|
60
70
|
m.template "config/environment.rb", "config/environment.rb"
|
61
71
|
m.directory "config/environments"
|
@@ -64,6 +74,10 @@ class DaemonKitGenerator < RubiGen::Base
|
|
64
74
|
m.file "config/pre-daemonize/readme", "config/pre-daemonize/readme"
|
65
75
|
m.directory "config/post-daemonize"
|
66
76
|
m.file "config/post-daemonize/readme", "config/post-daemonize/readme"
|
77
|
+
m.directory "script"
|
78
|
+
m.file "script/destroy", "script/destroy"
|
79
|
+
m.file "script/console", "script/console"
|
80
|
+
m.file "script/generate", "script/generate"
|
67
81
|
|
68
82
|
# Libraries
|
69
83
|
m.directory "lib"
|
@@ -75,6 +89,11 @@ class DaemonKitGenerator < RubiGen::Base
|
|
75
89
|
# Tests
|
76
90
|
m.dependency "install_rspec", [daemon_name], :destination => destination_root, :collision => :force
|
77
91
|
|
92
|
+
# Deployers
|
93
|
+
unless deployer == 'none'
|
94
|
+
m.dependency "deploy_#{deployer}", [daemon_name], :destination => destination_root, :collision => :force
|
95
|
+
end
|
96
|
+
|
78
97
|
# Others
|
79
98
|
m.directory "log"
|
80
99
|
m.directory "tmp"
|
@@ -102,12 +121,21 @@ EOS
|
|
102
121
|
# opts.on("-a", "--author=\"Your Name\"", String,
|
103
122
|
# "Some comment about this option",
|
104
123
|
# "Default: none") { |o| options[:author] = o }
|
124
|
+
|
105
125
|
opts.on("-i", "--install=generator", String,
|
106
126
|
"Select a generator to use (other than the default).",
|
107
127
|
"Available generators: #{VALID_GENERATORS.join(', ')}",
|
108
128
|
"Defaults to: default") do |installer|
|
109
129
|
options[:installer] = installer
|
110
130
|
end
|
131
|
+
|
132
|
+
opts.on("-d", "--deploy-with=config", String,
|
133
|
+
"Select an optional deployment mechanism.",
|
134
|
+
"Available deployers: #{DEPLOYERS.join(', ')}",
|
135
|
+
"Defaults to: none") do |deploy|
|
136
|
+
options[:deployer] = deploy
|
137
|
+
end
|
138
|
+
|
111
139
|
opts.on("-r", "--ruby=path", String,
|
112
140
|
"Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
|
113
141
|
"Default: #{DEFAULT_SHEBANG}") { |x| options[:shebang] = x }
|
@@ -120,6 +148,7 @@ EOS
|
|
120
148
|
# raw instance variable value.
|
121
149
|
# @author = options[:author]
|
122
150
|
@installer = options[:installer] || 'default'
|
151
|
+
@deployer = (options[:deployer] || 'none').strip
|
123
152
|
end
|
124
153
|
|
125
154
|
end
|
@@ -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
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Don't change this file!
|
2
2
|
# Configure your daemon in config/environment.rb
|
3
3
|
|
4
|
-
DAEMON_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?( DAEMON_ROOT )
|
4
|
+
DAEMON_ROOT = "#{File.expand_path(File.dirname(__FILE__))}/.." unless defined?( DAEMON_ROOT )
|
5
5
|
|
6
6
|
module DaemonKit
|
7
7
|
class << self
|
@@ -36,7 +36,7 @@ module DaemonKit
|
|
36
36
|
require "#{DAEMON_ROOT}/vendor/daemon_kit/lib/daemon_kit/initializer"
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
class GemBoot < Boot
|
41
41
|
def load_initializer
|
42
42
|
begin
|