bunnicula 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/bunnicula.gemspec +180 -3
- data/lib/bunnicula/version.rb +1 -1
- data/vendor/daemon_kit/daemon-kit/Configuration.txt +110 -0
- data/vendor/daemon_kit/daemon-kit/Deployment.txt +113 -0
- data/vendor/daemon_kit/daemon-kit/History.txt +113 -0
- data/vendor/daemon_kit/daemon-kit/Logging.txt +96 -0
- data/vendor/daemon_kit/daemon-kit/Manifest.txt +172 -0
- data/vendor/daemon_kit/daemon-kit/PostInstall.txt +6 -0
- data/vendor/daemon_kit/daemon-kit/README.rdoc +126 -0
- data/vendor/daemon_kit/daemon-kit/Rakefile +29 -0
- data/vendor/daemon_kit/daemon-kit/RuoteParticipants.txt +113 -0
- data/vendor/daemon_kit/daemon-kit/TODO.txt +28 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/USAGE +7 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/daemon_kit_generator.rb +178 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/README +48 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/Rakefile +6 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/bin/daemon.erb +7 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/arguments.rb +12 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/boot.rb +59 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/environment.rb +23 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/environments/development.rb +2 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/environments/production.rb +5 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/environments/test.rb +2 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/post-daemonize/readme +5 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/pre-daemonize/readme +12 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/lib/daemon.rb +2 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/libexec/daemon.erb +18 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/script/console +3 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/script/destroy +14 -0
- data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/script/generate +14 -0
- data/vendor/daemon_kit/daemon-kit/bin/daemon-kit +18 -0
- data/vendor/daemon_kit/daemon-kit/config/website.yml +2 -0
- data/vendor/daemon_kit/daemon-kit/daemon-kit.gemspec +264 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/USAGE +5 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/amqp_generator.rb +65 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/templates/config/amqp.yml +28 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/templates/config/initializers/amqp.rb +7 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/templates/libexec/daemon.rb +37 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cron/USAGE +5 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cron/cron_generator.rb +64 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cron/templates/config/initializers/cron.rb +11 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cron/templates/libexec/daemon.rb +43 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/USAGE +11 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/cucumber_generator.rb +38 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/templates/cucumber +8 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/templates/cucumber.rake +13 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/templates/cucumber_environment.rb +2 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/templates/env.rb +7 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +35 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/Capfile +10 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/USAGE +10 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy.rb +53 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +6 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +6 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/config/environments/staging.rb +0 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/USAGE +5 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/jabber_generator.rb +65 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/templates/config/initializers/jabber.rb +7 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/templates/config/jabber.yml +26 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/templates/libexec/daemon.rb +27 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/USAGE +5 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/nanite_agent_generator.rb +68 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/templates/config/initializers/nanite_agent.rb +6 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/templates/config/nanite.yml +35 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/templates/lib/actors/sample.rb +11 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/templates/libexec/daemon.rb +31 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/USAGE +5 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/rspec_generator.rb +55 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/templates/spec.rb +11 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/templates/spec/spec.opts +1 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/templates/spec/spec_helper.rb +23 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/templates/tasks/rspec.rake +19 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/USAGE +5 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/ruote_generator.rb +67 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/config/amqp.yml +30 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/config/initializers/ruote.rb +13 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/config/ruote.yml +23 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/lib/daemon.rb +4 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/lib/sample.rb +26 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/libexec/daemon.rb +33 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/USAGE +5 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/templates/tasks/test_unit.rake +7 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/templates/test/test.rb +9 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/templates/test/test_helper.rb +6 -0
- data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/test_unit_generator.rb +51 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit.rb +62 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/abstract_logger.rb +241 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/amqp.rb +38 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/application.rb +188 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/arguments.rb +170 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/commands/console.rb +38 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/config.rb +108 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/console_daemon.rb +2 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/core_ext.rb +1 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/core_ext/configurable.rb +96 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/core_ext/string.rb +22 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/cron.rb +48 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/cucumber/world.rb +38 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/deployment/capistrano.rb +482 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/em.rb +43 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/error_handlers/base.rb +32 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/error_handlers/hoptoad.rb +61 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/error_handlers/mail.rb +85 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/exceptions.rb +15 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/initializer.rb +453 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/jabber.rb +170 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/nanite.rb +7 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/nanite/agent.rb +77 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/pid_file.rb +61 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/ruote_participants.rb +119 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/ruote_workitem.rb +177 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/safety.rb +85 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks.rb +2 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/environment.rake +10 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/framework.rake +120 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/god.rake +62 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/log.rake +8 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/monit.rake +29 -0
- data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/xmpp.rb +31 -0
- data/vendor/daemon_kit/daemon-kit/script/console +10 -0
- data/vendor/daemon_kit/daemon-kit/script/destroy +14 -0
- data/vendor/daemon_kit/daemon-kit/script/generate +14 -0
- data/vendor/daemon_kit/daemon-kit/script/txt2html +71 -0
- data/vendor/daemon_kit/daemon-kit/spec/abstract_logger_spec.rb +126 -0
- data/vendor/daemon_kit/daemon-kit/spec/argument_spec.rb +70 -0
- data/vendor/daemon_kit/daemon-kit/spec/config_spec.rb +79 -0
- data/vendor/daemon_kit/daemon-kit/spec/configurable_spec.rb +56 -0
- data/vendor/daemon_kit/daemon-kit/spec/daemon_kit_spec.rb +7 -0
- data/vendor/daemon_kit/daemon-kit/spec/error_handlers_spec.rb +23 -0
- data/vendor/daemon_kit/daemon-kit/spec/fixtures/env.yml +15 -0
- data/vendor/daemon_kit/daemon-kit/spec/fixtures/noenv.yml +4 -0
- data/vendor/daemon_kit/daemon-kit/spec/initializer_spec.rb +26 -0
- data/vendor/daemon_kit/daemon-kit/spec/spec.opts +1 -0
- data/vendor/daemon_kit/daemon-kit/spec/spec_helper.rb +27 -0
- data/vendor/daemon_kit/daemon-kit/tasks/cucumber.rake +13 -0
- data/vendor/daemon_kit/daemon-kit/tasks/rspec.rake +21 -0
- data/vendor/daemon_kit/daemon-kit/tasks/tests.rake +6 -0
- data/vendor/daemon_kit/daemon-kit/templates/god/god.erb +69 -0
- data/vendor/daemon_kit/daemon-kit/templates/monit/monit.erb +14 -0
- data/vendor/daemon_kit/daemon-kit/test/test_amqp_generator.rb +48 -0
- data/vendor/daemon_kit/daemon-kit/test/test_cron_generator.rb +45 -0
- data/vendor/daemon_kit/daemon-kit/test/test_daemon-kit_generator.rb +84 -0
- data/vendor/daemon_kit/daemon-kit/test/test_daemon_kit_config.rb +28 -0
- data/vendor/daemon_kit/daemon-kit/test/test_deploy_capistrano_generator.rb +48 -0
- data/vendor/daemon_kit/daemon-kit/test/test_generator_helper.rb +29 -0
- data/vendor/daemon_kit/daemon-kit/test/test_helper.rb +7 -0
- data/vendor/daemon_kit/daemon-kit/test/test_jabber_generator.rb +49 -0
- data/vendor/daemon_kit/daemon-kit/test/test_nanite_agent_generator.rb +49 -0
- data/vendor/daemon_kit/daemon-kit/test/test_ruote_generator.rb +51 -0
- data/vendor/daemon_kit/daemon-kit/test/test_test_unit_generator.rb +46 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail.rb +5 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/address.rb +426 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/attachments.rb +46 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/base64.rb +46 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/compat.rb +41 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/config.rb +67 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/core_extensions.rb +63 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/encode.rb +581 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/header.rb +960 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/index.rb +9 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/interface.rb +1130 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/loader.rb +3 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/mail.rb +578 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/mailbox.rb +495 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/main.rb +6 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/mbox.rb +3 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/net.rb +248 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/obsolete.rb +132 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/parser.rb +1476 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/port.rb +379 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/quoting.rb +118 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/scanner.rb +49 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/scanner_r.rb +261 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/stringio.rb +280 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/utils.rb +337 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/version.rb +39 -0
- data/vendor/daemon_kit/daemon-kit/vendor/tmail.rb +13 -0
- metadata +181 -4
@@ -0,0 +1,28 @@
|
|
1
|
+
= DaemonKit TODO List
|
2
|
+
|
3
|
+
This is purely a drop in the bucket of what has to come...
|
4
|
+
|
5
|
+
* Support for chroot'ing
|
6
|
+
* Altering process names (fully and temporary appending)
|
7
|
+
* bleak_house support
|
8
|
+
* Support for tweaking REE environment variables prior to launch (bash wrapper)
|
9
|
+
* Clustering support (run multiple workers out of same project)
|
10
|
+
* [IN PROGRESS] Error handling to the degree Rails does
|
11
|
+
* Support for custom error handlers in the project
|
12
|
+
* Easy configuration of an ORM of choice, including patching it if needed (ActiveRecord *cough*)
|
13
|
+
* Improved generators for creating skeleton daemons:
|
14
|
+
* Evented jabber bot
|
15
|
+
* Empty periodic event loop
|
16
|
+
* Empty periodic loop (non-evented)
|
17
|
+
* Queue (SQS, AMQP, etc) pollers
|
18
|
+
* Rake tasks for generating:
|
19
|
+
* Sys-V style init scripts
|
20
|
+
* Plenty of docs, seriously a lot of docs
|
21
|
+
* Specs & features, tons of them too
|
22
|
+
* Integration tests for the specific daemons
|
23
|
+
* Some level of thread safety, or mechanisms to ease thread safety
|
24
|
+
* Built in utilities:
|
25
|
+
* Fibre pool for 1.9
|
26
|
+
* Some activesupport-esque functions until activesupport 3.0 hits the streets
|
27
|
+
* DRY up the following:
|
28
|
+
* Loading configuration files for the daemons
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Description:
|
2
|
+
This generator creates a new skeleton project suitable for easy
|
3
|
+
Ruby daemon development. The generated project is preconfigured
|
4
|
+
and just requires your task specific code.
|
5
|
+
|
6
|
+
Use one of the provided generators to stub out even more
|
7
|
+
functionality for common daemon patterns.
|
@@ -0,0 +1,178 @@
|
|
1
|
+
class DaemonKitGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
4
|
+
Config::CONFIG['ruby_install_name'])
|
5
|
+
|
6
|
+
VALID_GENERATORS = ['default', 'jabber', 'cron', 'amqp', 'nanite_agent', 'ruote']
|
7
|
+
|
8
|
+
DEPLOYERS = ['none', 'capistrano']
|
9
|
+
|
10
|
+
TEST_FRAMEWORKS = [ 'rspec', 'test_unit' ]
|
11
|
+
|
12
|
+
default_options :shebang => DEFAULT_SHEBANG, :author => nil
|
13
|
+
|
14
|
+
attr_reader :daemon_name
|
15
|
+
attr_reader :installer
|
16
|
+
attr_reader :deployer
|
17
|
+
attr_reader :cucumber
|
18
|
+
attr_reader :test_framework
|
19
|
+
|
20
|
+
def initialize(runtime_args, runtime_options = {})
|
21
|
+
super
|
22
|
+
usage if args.empty?
|
23
|
+
@destination_root = File.expand_path(args.shift)
|
24
|
+
@daemon_name = base_name
|
25
|
+
extract_options
|
26
|
+
end
|
27
|
+
|
28
|
+
def manifest
|
29
|
+
# ensure some sanity
|
30
|
+
unless VALID_GENERATORS.include?( installer )
|
31
|
+
$stderr.puts "Invalid generator: '#{installer}'."
|
32
|
+
$stderr.puts "Valid generators are: #{VALID_GENERATORS.join(', ')}"
|
33
|
+
exit 1
|
34
|
+
end
|
35
|
+
|
36
|
+
unless DEPLOYERS.include?( deployer )
|
37
|
+
$stderr.puts "Invalid deployment mechanism: '#{deployer}'."
|
38
|
+
$stderr.puts "Valid deployers are: #{DEPLOYERS.join(', ')}"
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
|
43
|
+
|
44
|
+
record do |m|
|
45
|
+
# Ensure appropriate folder(s) exists
|
46
|
+
m.directory ''
|
47
|
+
|
48
|
+
# Create stubs
|
49
|
+
# m.template "template.rb", "some_file_after_erb.rb"
|
50
|
+
# m.template_copy_each ["template.rb", "template2.rb"]
|
51
|
+
# m.file "file", "some_file_copied"
|
52
|
+
# m.file_copy_each ["path/to/file", "path/to/file2"]
|
53
|
+
|
54
|
+
# Readme
|
55
|
+
m.template "README", "README"
|
56
|
+
m.template "Rakefile", "Rakefile"
|
57
|
+
|
58
|
+
# Executable
|
59
|
+
m.directory "bin"
|
60
|
+
m.template "bin/daemon.erb", "bin/#{daemon_name}", script_options
|
61
|
+
|
62
|
+
# Generator
|
63
|
+
if installer == "default"
|
64
|
+
m.directory "libexec"
|
65
|
+
m.template "libexec/daemon.erb", "libexec/#{daemon_name}-daemon.rb"
|
66
|
+
else
|
67
|
+
m.dependency installer, [daemon_name], :destination => destination_root, :collision => :force
|
68
|
+
end
|
69
|
+
|
70
|
+
# Config/Environment
|
71
|
+
m.directory "config"
|
72
|
+
m.file "config/arguments.rb", "config/arguments.rb"
|
73
|
+
m.file "config/boot.rb", "config/boot.rb"
|
74
|
+
m.template "config/environment.rb", "config/environment.rb"
|
75
|
+
m.directory "config/environments"
|
76
|
+
%w{ development test production }.each { |f| m.file "config/environments/#{f}.rb", "config/environments/#{f}.rb" }
|
77
|
+
m.directory "config/pre-daemonize"
|
78
|
+
m.file "config/pre-daemonize/readme", "config/pre-daemonize/readme"
|
79
|
+
m.directory "config/post-daemonize"
|
80
|
+
m.file "config/post-daemonize/readme", "config/post-daemonize/readme"
|
81
|
+
m.directory "script"
|
82
|
+
m.file "script/destroy", "script/destroy", script_options
|
83
|
+
m.file "script/console", "script/console", script_options
|
84
|
+
m.file "script/generate", "script/generate", script_options
|
85
|
+
|
86
|
+
# Libraries
|
87
|
+
m.directory "lib"
|
88
|
+
m.file "lib/daemon.rb", "lib/#{daemon_name}.rb", :collision => :skip
|
89
|
+
|
90
|
+
# Tasks
|
91
|
+
m.directory "tasks"
|
92
|
+
|
93
|
+
# Tests
|
94
|
+
case test_framework
|
95
|
+
when 'rspec'
|
96
|
+
m.dependency "rspec", [daemon_name], :destination => destination_root, :collision => :force
|
97
|
+
when 'test_unit'
|
98
|
+
m.dependency "test_unit", [daemon_name], :destination => destination_root, :collision => :force
|
99
|
+
end
|
100
|
+
|
101
|
+
if cucumber
|
102
|
+
m.dependency "cucumber", [], :destination => destination_root, :collision => :force
|
103
|
+
end
|
104
|
+
|
105
|
+
# Deployers
|
106
|
+
unless deployer == 'none'
|
107
|
+
m.dependency "deploy_#{deployer}", [daemon_name], :destination => destination_root, :collision => :force
|
108
|
+
end
|
109
|
+
|
110
|
+
# Others
|
111
|
+
m.directory "log"
|
112
|
+
m.directory "tmp"
|
113
|
+
m.directory "vendor"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
protected
|
118
|
+
def banner
|
119
|
+
<<-EOS
|
120
|
+
Creates a preconfigured environment for writing Ruby daemon processes.
|
121
|
+
|
122
|
+
USAGE: #{spec.name} /path/to/your/daemon [options]
|
123
|
+
EOS
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_options!(opts)
|
127
|
+
opts.separator ''
|
128
|
+
opts.separator 'Options:'
|
129
|
+
# For each option below, place the default
|
130
|
+
# at the top of the file next to "default_options"
|
131
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
132
|
+
# "Some comment about this option",
|
133
|
+
# "Default: none") { |o| options[:author] = o }
|
134
|
+
|
135
|
+
opts.on("-i", "--install=generator", String,
|
136
|
+
"Select a generator to use (other than the default).",
|
137
|
+
"Available generators: #{VALID_GENERATORS.join(', ')}",
|
138
|
+
"Defaults to: default") do |installer|
|
139
|
+
options[:installer] = installer
|
140
|
+
end
|
141
|
+
|
142
|
+
opts.on("-d", "--deploy-with=config", String,
|
143
|
+
"Select an optional deployment mechanism.",
|
144
|
+
"Available deployers: #{DEPLOYERS.join(', ')}",
|
145
|
+
"Defaults to: none") do |deploy|
|
146
|
+
options[:deployer] = deploy
|
147
|
+
end
|
148
|
+
|
149
|
+
opts.on("-T", "--test-with=type", String,
|
150
|
+
"Select your test framework.",
|
151
|
+
"Available test framworks: #{TEST_FRAMEWORKS.join(', ')}",
|
152
|
+
"Defaults to: rspec") do |test|
|
153
|
+
options[:test_framework] = test
|
154
|
+
end
|
155
|
+
|
156
|
+
opts.on("--cucumber",
|
157
|
+
"Install cucumber.") do
|
158
|
+
options[:cucumber] = true
|
159
|
+
end
|
160
|
+
|
161
|
+
opts.on("-r", "--ruby=path", String,
|
162
|
+
"Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
|
163
|
+
"Default: #{DEFAULT_SHEBANG}") { |x| options[:shebang] = x }
|
164
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
165
|
+
end
|
166
|
+
|
167
|
+
def extract_options
|
168
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
169
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
170
|
+
# raw instance variable value.
|
171
|
+
# @author = options[:author]
|
172
|
+
@installer = options[:installer] || 'default'
|
173
|
+
@deployer = (options[:deployer] || 'none').strip
|
174
|
+
@cucumber = options[:cucumber] || false
|
175
|
+
@test_framework = options[:test_framework] || 'rspec'
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
DaemonKit README
|
2
|
+
================
|
3
|
+
|
4
|
+
DaemonKit 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
|
+
<%= daemon_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
|
+
<%= daemon_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 gettign insight into what your
|
42
|
+
daemons are doing. Logging with DaemonKit 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.
|
@@ -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,59 @@
|
|
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
|
+
module DaemonKit
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
pick_boot.run
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def booted?
|
15
|
+
defined? DaemonKit::Initializer
|
16
|
+
end
|
17
|
+
|
18
|
+
def pick_boot
|
19
|
+
(vendor_kit? ? VendorBoot : GemBoot).new
|
20
|
+
end
|
21
|
+
|
22
|
+
def vendor_kit?
|
23
|
+
File.exists?( "#{DAEMON_ROOT}/vendor/daemon_kit" )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Boot
|
28
|
+
def run
|
29
|
+
load_initializer
|
30
|
+
DaemonKit::Initializer.run
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class VendorBoot < Boot
|
35
|
+
def load_initializer
|
36
|
+
require "#{DAEMON_ROOT}/vendor/daemon_kit/lib/daemon_kit/initializer"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class GemBoot < Boot
|
41
|
+
def load_initializer
|
42
|
+
begin
|
43
|
+
gem 'daemon-kit'
|
44
|
+
require 'daemon_kit/initializer'
|
45
|
+
rescue Gem::LoadError => e
|
46
|
+
msg = <<EOF
|
47
|
+
You are missing the daemon-kit gem. Please install the following gems:
|
48
|
+
|
49
|
+
* Stable - sudo gem install daemon-kit
|
50
|
+
|
51
|
+
EOF
|
52
|
+
$stderr.puts msg
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
DaemonKit.boot!
|
@@ -0,0 +1,23 @@
|
|
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
|
+
DaemonKit::Initializer.run do |config|
|
10
|
+
|
11
|
+
# The name of the daemon as reported by process monitoring tools
|
12
|
+
config.daemon_name = '<%= daemon_name %>'
|
13
|
+
|
14
|
+
# Force the daemon to be killed after X seconds from asking it to
|
15
|
+
# config.force_kill_wait = 30
|
16
|
+
|
17
|
+
# Log backraces when a thread/daemon dies (Recommended)
|
18
|
+
# config.backtraces = true
|
19
|
+
|
20
|
+
# Configure the safety net (see DaemonKit::Safety)
|
21
|
+
# config.safety_net.handler = :mail # (or :hoptoad )
|
22
|
+
# config.safety_net.mail.host = 'localhost'
|
23
|
+
end
|
data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/pre-daemonize/readme
ADDED
@@ -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,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:daemon, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|