apphunkd 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +78 -0
- data/TODO +1 -0
- data/VERSION +1 -0
- data/apphunkd.gemspec +258 -0
- data/bin/apphunkd +4 -0
- data/config/arguments.rb +12 -0
- data/config/boot.rb +68 -0
- data/config/environment.rb +23 -0
- data/config/environments/development.rb +2 -0
- data/config/environments/production.rb +2 -0
- data/config/environments/test.rb +2 -0
- data/config/post-daemonize/readme +5 -0
- data/config/pre-daemonize/readme +12 -0
- data/config/pre-daemonize/requires.rb +2 -0
- data/lib/apphunkd.rb +25 -0
- data/lib/apphunkd/api.rb +5 -0
- data/lib/apphunkd/api/service.rb +27 -0
- data/lib/apphunkd/queue.rb +96 -0
- data/lib/apphunkd/remote.rb +29 -0
- data/lib/apphunkd/remote/result.rb +15 -0
- data/libexec/apphunkd-daemon.rb +13 -0
- data/script/console +3 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/lib/apphunkd/api/service_spec.rb +47 -0
- data/spec/lib/apphunkd/queue_spec.rb +129 -0
- data/spec/lib/apphunkd/remote_spec.rb +61 -0
- data/spec/lib/apphunkd_spec.rb +50 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +13 -0
- data/support/apphunkd.initd +47 -0
- data/support/apphunkd.monitrc +3 -0
- data/tasks/rspec.rake +21 -0
- data/vendor/daemon-kit/Configuration.txt +102 -0
- data/vendor/daemon-kit/Deployment.txt +113 -0
- data/vendor/daemon-kit/History.txt +97 -0
- data/vendor/daemon-kit/Logging.txt +92 -0
- data/vendor/daemon-kit/Manifest.txt +166 -0
- data/vendor/daemon-kit/PostInstall.txt +6 -0
- data/vendor/daemon-kit/README.rdoc +130 -0
- data/vendor/daemon-kit/Rakefile +37 -0
- data/vendor/daemon-kit/RuoteParticipants.txt +113 -0
- data/vendor/daemon-kit/TODO.txt +37 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/USAGE +7 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/daemon_kit_generator.rb +161 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/README +48 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/Rakefile +6 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/bin/daemon.erb +7 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/arguments.rb +12 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/boot.rb +68 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environment.rb +23 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/development.rb +2 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/production.rb +2 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/test.rb +2 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/post-daemonize/readme +5 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/pre-daemonize/readme +12 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/lib/daemon.rb +2 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/libexec/daemon.erb +18 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/console +3 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/destroy +14 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/generate +14 -0
- data/vendor/daemon-kit/bin/daemon_kit +18 -0
- data/vendor/daemon-kit/daemon_generators/amqp/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/amqp/amqp_generator.rb +65 -0
- data/vendor/daemon-kit/daemon_generators/amqp/templates/config/amqp.yml +28 -0
- data/vendor/daemon-kit/daemon_generators/amqp/templates/config/initializers/amqp.rb +7 -0
- data/vendor/daemon-kit/daemon_generators/amqp/templates/libexec/daemon.rb +37 -0
- data/vendor/daemon-kit/daemon_generators/cron/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/cron/cron_generator.rb +64 -0
- data/vendor/daemon-kit/daemon_generators/cron/templates/config/initializers/cron.rb +11 -0
- data/vendor/daemon-kit/daemon_generators/cron/templates/libexec/daemon.rb +43 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/USAGE +11 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/cucumber_generator.rb +38 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber +8 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber.rake +13 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber_environment.rb +2 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/templates/env.rb +7 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +35 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/Capfile +10 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/USAGE +10 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy.rb +53 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +6 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +6 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/environments/staging.rb +0 -0
- data/vendor/daemon-kit/daemon_generators/jabber/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/jabber/jabber_generator.rb +65 -0
- data/vendor/daemon-kit/daemon_generators/jabber/templates/config/initializers/jabber.rb +7 -0
- data/vendor/daemon-kit/daemon_generators/jabber/templates/config/jabber.yml +26 -0
- data/vendor/daemon-kit/daemon_generators/jabber/templates/libexec/daemon.rb +27 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/nanite_agent_generator.rb +68 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/config/initializers/nanite_agent.rb +6 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/config/nanite.yml +35 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/lib/actors/sample.rb +11 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/libexec/daemon.rb +31 -0
- data/vendor/daemon-kit/daemon_generators/rspec/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/rspec/rspec_generator.rb +55 -0
- data/vendor/daemon-kit/daemon_generators/rspec/templates/spec.rb +11 -0
- data/vendor/daemon-kit/daemon_generators/rspec/templates/spec/spec.opts +1 -0
- data/vendor/daemon-kit/daemon_generators/rspec/templates/spec/spec_helper.rb +21 -0
- data/vendor/daemon-kit/daemon_generators/rspec/templates/tasks/rspec.rake +21 -0
- data/vendor/daemon-kit/daemon_generators/ruote/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/ruote/ruote_generator.rb +67 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/config/amqp.yml +30 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/config/initializers/ruote.rb +13 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/config/ruote.yml +23 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/lib/daemon.rb +4 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/lib/sample.rb +26 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/libexec/daemon.rb +33 -0
- data/vendor/daemon-kit/lib/daemon_kit.rb +54 -0
- data/vendor/daemon-kit/lib/daemon_kit/abstract_logger.rb +235 -0
- data/vendor/daemon-kit/lib/daemon_kit/amqp.rb +38 -0
- data/vendor/daemon-kit/lib/daemon_kit/application.rb +187 -0
- data/vendor/daemon-kit/lib/daemon_kit/arguments.rb +165 -0
- data/vendor/daemon-kit/lib/daemon_kit/commands/console.rb +38 -0
- data/vendor/daemon-kit/lib/daemon_kit/config.rb +108 -0
- data/vendor/daemon-kit/lib/daemon_kit/console_daemon.rb +2 -0
- data/vendor/daemon-kit/lib/daemon_kit/core_ext.rb +1 -0
- data/vendor/daemon-kit/lib/daemon_kit/core_ext/configurable.rb +96 -0
- data/vendor/daemon-kit/lib/daemon_kit/core_ext/string.rb +22 -0
- data/vendor/daemon-kit/lib/daemon_kit/cron.rb +48 -0
- data/vendor/daemon-kit/lib/daemon_kit/cucumber/world.rb +38 -0
- data/vendor/daemon-kit/lib/daemon_kit/deployment/capistrano.rb +482 -0
- data/vendor/daemon-kit/lib/daemon_kit/em.rb +43 -0
- data/vendor/daemon-kit/lib/daemon_kit/error_handlers/base.rb +32 -0
- data/vendor/daemon-kit/lib/daemon_kit/error_handlers/hoptoad.rb +61 -0
- data/vendor/daemon-kit/lib/daemon_kit/error_handlers/mail.rb +85 -0
- data/vendor/daemon-kit/lib/daemon_kit/exceptions.rb +8 -0
- data/vendor/daemon-kit/lib/daemon_kit/initializer.rb +438 -0
- data/vendor/daemon-kit/lib/daemon_kit/jabber.rb +170 -0
- data/vendor/daemon-kit/lib/daemon_kit/nanite.rb +7 -0
- data/vendor/daemon-kit/lib/daemon_kit/nanite/agent.rb +56 -0
- data/vendor/daemon-kit/lib/daemon_kit/pid_file.rb +61 -0
- data/vendor/daemon-kit/lib/daemon_kit/ruote_participants.rb +119 -0
- data/vendor/daemon-kit/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
- data/vendor/daemon-kit/lib/daemon_kit/ruote_workitem.rb +169 -0
- data/vendor/daemon-kit/lib/daemon_kit/safety.rb +85 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks.rb +2 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/environment.rake +10 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/framework.rake +120 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/god.rake +62 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/log.rake +8 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/monit.rake +29 -0
- data/vendor/daemon-kit/script/console +10 -0
- data/vendor/daemon-kit/script/destroy +14 -0
- data/vendor/daemon-kit/script/generate +14 -0
- data/vendor/daemon-kit/script/txt2html +71 -0
- data/vendor/daemon-kit/spec/abstract_logger_spec.rb +126 -0
- data/vendor/daemon-kit/spec/argument_spec.rb +70 -0
- data/vendor/daemon-kit/spec/config_spec.rb +79 -0
- data/vendor/daemon-kit/spec/configurable_spec.rb +56 -0
- data/vendor/daemon-kit/spec/daemon_kit_spec.rb +7 -0
- data/vendor/daemon-kit/spec/error_handlers_spec.rb +23 -0
- data/vendor/daemon-kit/spec/fixtures/env.yml +15 -0
- data/vendor/daemon-kit/spec/fixtures/noenv.yml +4 -0
- data/vendor/daemon-kit/spec/initializer_spec.rb +26 -0
- data/vendor/daemon-kit/spec/spec.opts +1 -0
- data/vendor/daemon-kit/spec/spec_helper.rb +27 -0
- data/vendor/daemon-kit/tasks/rspec.rake +21 -0
- data/vendor/daemon-kit/templates/god/god.erb +69 -0
- data/vendor/daemon-kit/templates/monit/monit.erb +14 -0
- data/vendor/daemon-kit/test/test_amqp_generator.rb +48 -0
- data/vendor/daemon-kit/test/test_cron_generator.rb +45 -0
- data/vendor/daemon-kit/test/test_daemon-kit_generator.rb +84 -0
- data/vendor/daemon-kit/test/test_daemon_kit_config.rb +28 -0
- data/vendor/daemon-kit/test/test_deploy_capistrano_generator.rb +48 -0
- data/vendor/daemon-kit/test/test_generator_helper.rb +29 -0
- data/vendor/daemon-kit/test/test_helper.rb +7 -0
- data/vendor/daemon-kit/test/test_jabber_generator.rb +49 -0
- data/vendor/daemon-kit/test/test_nanite_agent_generator.rb +49 -0
- data/vendor/daemon-kit/test/test_ruote_generator.rb +45 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail.rb +5 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/address.rb +426 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/attachments.rb +46 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/base64.rb +46 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/compat.rb +41 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/config.rb +67 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/core_extensions.rb +63 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/encode.rb +581 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/header.rb +960 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/index.rb +9 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/interface.rb +1130 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/loader.rb +3 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mail.rb +578 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mailbox.rb +495 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/main.rb +6 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mbox.rb +3 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/net.rb +248 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/obsolete.rb +132 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/parser.rb +1476 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/port.rb +379 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/quoting.rb +118 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/scanner.rb +49 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/scanner_r.rb +261 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/stringio.rb +280 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/utils.rb +337 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/version.rb +39 -0
- data/vendor/daemon-kit/vendor/tmail.rb +13 -0
- metadata +281 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe DaemonKit::Safety do
|
4
|
+
end
|
5
|
+
|
6
|
+
describe DaemonKit::ErrorHandlers::Mail do
|
7
|
+
it "should send an email report" do
|
8
|
+
conf = Object.new
|
9
|
+
conf.stubs(:daemon_name).returns('test')
|
10
|
+
DaemonKit.stubs(:configuration).returns(conf)
|
11
|
+
|
12
|
+
fake_smtp = Object.new
|
13
|
+
fake_smtp.expects(:start).with('localhost.localdomain', nil, nil, nil)
|
14
|
+
Net::SMTP.expects(:new).with('localhost', 25).returns(fake_smtp)
|
15
|
+
|
16
|
+
begin
|
17
|
+
raise RuntimeError, "specs don't fail :)"
|
18
|
+
rescue => e
|
19
|
+
handler = DaemonKit::ErrorHandlers::Mail.instance
|
20
|
+
handler.handle_exception( e )
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require 'daemon_kit/initializer'
|
3
|
+
|
4
|
+
describe DaemonKit::Configuration do
|
5
|
+
before(:each) do
|
6
|
+
@configuration = DaemonKit::Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should know our environment" do
|
10
|
+
@configuration.environment.should_not be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a default log path" do
|
14
|
+
@configuration.log_path.should_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have a default log level" do
|
18
|
+
@configuration.log_level.should_not be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should set a default umask" do
|
22
|
+
File.umask.should_not be(0)
|
23
|
+
File.umask.should be(18)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'rspec'
|
3
|
+
require 'spec'
|
4
|
+
|
5
|
+
require 'mocha'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
DAEMON_ENV = "test"
|
9
|
+
DAEMON_ROOT = "#{File.dirname(__FILE__)}/../tmp"
|
10
|
+
|
11
|
+
$:.unshift( File.dirname(__FILE__) + '/../lib' )
|
12
|
+
require 'daemon_kit'
|
13
|
+
|
14
|
+
Spec::Runner.configure do |config|
|
15
|
+
# == Mock Framework
|
16
|
+
#
|
17
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
18
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
19
|
+
#
|
20
|
+
config.mock_with :mocha
|
21
|
+
# config.mock_with :flexmock
|
22
|
+
# config.mock_with :rr
|
23
|
+
|
24
|
+
# setup a fake daemon_root
|
25
|
+
config.before(:all) { File.directory?( DAEMON_ROOT ) ? FileUtils.rm_rf("#{DAEMON_ROOT}/*") : FileUtils.mkdir_p( DAEMON_ROOT ) }
|
26
|
+
config.after(:all) { FileUtils.rm_rf("#{DAEMON_ROOT}/*") }
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# This is a configuration template for 'god' process monitoring.
|
3
|
+
#
|
4
|
+
# More information can be found at http://god.rubyforge.org/
|
5
|
+
#
|
6
|
+
|
7
|
+
DAEMON_ROOT = "<%= DaemonKit.root %>"
|
8
|
+
|
9
|
+
God.watch do |w|
|
10
|
+
w.name = '<%= DaemonKit.configuration.daemon_name %>'
|
11
|
+
w.interval = 30.seconds
|
12
|
+
w.start = "/usr/bin/env DAEMON_ENV=<%= DaemonKit.env %> <%= DaemonKit.root %>/bin/<%= DaemonKit.configuration.daemon_name %> start"
|
13
|
+
w.stop = "/usr/bin/env DAEMON_ENV=<%= DaemonKit.env %> <%= DaemonKit.root %>/bin/<%= DaemonKit.configuration.daemon_name %> stop"
|
14
|
+
w.start_grace = 10.seconds
|
15
|
+
w.stop_grace = 10.seconds
|
16
|
+
w.pid_file = "<%= DaemonKit.configuration.pid_file %>"
|
17
|
+
w.behavior(:clean_pid_file)
|
18
|
+
#w.uid = 'nobody'
|
19
|
+
#w.gid = 'nobody'
|
20
|
+
|
21
|
+
w.start_if do |start|
|
22
|
+
start.condition(:process_running) do |c|
|
23
|
+
c.interval = 30.seconds
|
24
|
+
c.running = false
|
25
|
+
c.notify = 'sysadmin'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
w.restart_if do |restart|
|
30
|
+
restart.condition(:memory_usage) do |c|
|
31
|
+
c.above = 250.megabytes
|
32
|
+
c.times = [3, 5] # 3 out of 5 intervals
|
33
|
+
c.notify = 'sysadmin'
|
34
|
+
end
|
35
|
+
|
36
|
+
restart.condition(:cpu_usage) do |c|
|
37
|
+
c.above = 50.percent
|
38
|
+
c.times = 5
|
39
|
+
c.notify = 'sysadmin'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
w.lifecycle do |on|
|
44
|
+
on.condition(:flapping) do |c|
|
45
|
+
c.to_state = [:start, :restart]
|
46
|
+
c.times = 5
|
47
|
+
c.within = 5.minute
|
48
|
+
c.transition = :unmonitored
|
49
|
+
c.retry_in = 10.minutes
|
50
|
+
c.retry_times = 5
|
51
|
+
c.retry_within = 2.hours
|
52
|
+
c.notify = 'sysadmin'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
God::Contacts::Email.server_settings = {
|
58
|
+
:address => "smtp.gmail.com",
|
59
|
+
:port => 587,
|
60
|
+
:domain => "localhost",
|
61
|
+
:authentication => :plain,
|
62
|
+
:user_name => "you@gmail.com",
|
63
|
+
:password => "secret"
|
64
|
+
}
|
65
|
+
|
66
|
+
God.contact(:email) do |c|
|
67
|
+
c.name = 'sysadmin'
|
68
|
+
c.email = 'you@gmail.com'
|
69
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#
|
2
|
+
# This monit configuration file is built from the monit wiki with some
|
3
|
+
# very basic checks on memory and CPU usage.
|
4
|
+
#
|
5
|
+
# See the man page at http://mmonit.com/monit/documentation/monit.html
|
6
|
+
# for more information.
|
7
|
+
#
|
8
|
+
check process <%= DaemonKit.configuration.daemon_name %> with pidfile <%= DaemonKit.configuration.pid_file %>
|
9
|
+
group daemons
|
10
|
+
start program = "/usr/bin/env DAEMON_ENV=<%= DaemonKit.env %> <%= DaemonKit.root %>/bin/<%= DaemonKit.configuration.daemon_name %> start"
|
11
|
+
stop program = "/usr/bin/env DAEMON_ENV=<%= DaemonKit.env %> <%= DaemonKit.root %>/bin/<%= DaemonKit.configuration.daemon_name %> stop"
|
12
|
+
if 5 restarts within 5 cycles then timeout
|
13
|
+
if cpu usage > 99% for 5 cycles then alert
|
14
|
+
if mem usage > 99% for 5 cycles then alert
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestAmqpGenerator < Test::Unit::TestCase
|
5
|
+
include RubiGen::GeneratorTestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
bare_setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
bare_teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
# Some generator-related assertions:
|
16
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
+
# assert_directory_exists(name)
|
18
|
+
# assert_generated_class(name, &block)
|
19
|
+
# assert_generated_module(name, &block)
|
20
|
+
# assert_generated_test_for(name, &block)
|
21
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
+
#
|
24
|
+
# Other helper methods are:
|
25
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
+
|
29
|
+
def test_generator_without_options
|
30
|
+
name = "myapp"
|
31
|
+
run_generator('amqp', [name], sources)
|
32
|
+
assert_directory_exists "config"
|
33
|
+
assert_directory_exists "config/initializers"
|
34
|
+
assert_generated_file "config/amqp.yml"
|
35
|
+
assert_generated_file "config/initializers/myapp.rb"
|
36
|
+
assert_generated_file "libexec/myapp-daemon.rb"
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def sources
|
41
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
def generator_path
|
46
|
+
"daemon_generators"
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestCronGenerator < Test::Unit::TestCase
|
5
|
+
include RubiGen::GeneratorTestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
bare_setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
bare_teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
# Some generator-related assertions:
|
16
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
+
# assert_directory_exists(name)
|
18
|
+
# assert_generated_class(name, &block)
|
19
|
+
# assert_generated_module(name, &block)
|
20
|
+
# assert_generated_test_for(name, &block)
|
21
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
+
#
|
24
|
+
# Other helper methods are:
|
25
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
+
|
29
|
+
def test_generator_without_options
|
30
|
+
name = "myapp"
|
31
|
+
run_generator('cron', [name], sources)
|
32
|
+
assert_directory_exists "config/initializers"
|
33
|
+
assert_generated_file "config/initializers/myapp.rb"
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def sources
|
38
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
def generator_path
|
43
|
+
"daemon_generators"
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
class TestDaemonKitGenerator < Test::Unit::TestCase
|
4
|
+
include RubiGen::GeneratorTestHelper
|
5
|
+
|
6
|
+
attr_reader :daemon_name
|
7
|
+
def setup
|
8
|
+
bare_setup
|
9
|
+
@daemon_name = File.basename(File.expand_path(APP_ROOT))
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
bare_teardown
|
14
|
+
end
|
15
|
+
|
16
|
+
# Some generator-related assertions:
|
17
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
18
|
+
# assert_directory_exists(name)
|
19
|
+
# assert_generated_class(name, &block)
|
20
|
+
# assert_generated_module(name, &block)
|
21
|
+
# assert_generated_test_for(name, &block)
|
22
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
23
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
24
|
+
#
|
25
|
+
# Other helper methods are:
|
26
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
27
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
28
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
29
|
+
|
30
|
+
def test_generator_without_options
|
31
|
+
run_generator('daemon_kit', [APP_ROOT], sources)
|
32
|
+
|
33
|
+
assert_generated_file "README"
|
34
|
+
assert_generated_file "Rakefile"
|
35
|
+
assert_directory_exists "bin"
|
36
|
+
assert_generated_file "bin/#{daemon_name}"
|
37
|
+
assert_directory_exists "config"
|
38
|
+
assert_generated_file "config/arguments.rb"
|
39
|
+
assert_generated_file "config/boot.rb"
|
40
|
+
assert_generated_file "config/environment.rb"
|
41
|
+
assert_generated_file "config/environments/development.rb"
|
42
|
+
assert_generated_file "config/environments/test.rb"
|
43
|
+
assert_generated_file "config/environments/production.rb"
|
44
|
+
assert_directory_exists "config/pre-daemonize"
|
45
|
+
assert_generated_file "config/pre-daemonize/readme"
|
46
|
+
assert_directory_exists "config/post-daemonize"
|
47
|
+
assert_generated_file "config/post-daemonize/readme"
|
48
|
+
assert_directory_exists "lib"
|
49
|
+
assert_generated_file "lib/#{daemon_name}.rb"
|
50
|
+
assert_directory_exists "libexec"
|
51
|
+
assert_generated_file "libexec/#{daemon_name}-daemon.rb"
|
52
|
+
assert_directory_exists "log"
|
53
|
+
assert_directory_exists "script"
|
54
|
+
assert_generated_file "script/console"
|
55
|
+
assert_generated_file "script/destroy"
|
56
|
+
assert_generated_file "script/generate"
|
57
|
+
assert_directory_exists "spec"
|
58
|
+
assert_directory_exists "tasks"
|
59
|
+
assert_directory_exists "vendor"
|
60
|
+
assert_directory_exists "tmp"
|
61
|
+
|
62
|
+
assert !File.exists?("#{APP_ROOT}/Capfile"), 'Capfile generated, but should not be'
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_generator_with_capistrano_deployer
|
66
|
+
run_generator('daemon_kit', [APP_ROOT, '-d capistrano'], sources)
|
67
|
+
|
68
|
+
assert_generated_file "Capfile"
|
69
|
+
assert_generated_file "config/deploy.rb"
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
def sources
|
74
|
+
[
|
75
|
+
RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path)),
|
76
|
+
RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "daemon_generators")),
|
77
|
+
RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "rubygems_generators"))
|
78
|
+
]
|
79
|
+
end
|
80
|
+
|
81
|
+
def generator_path
|
82
|
+
"app_generators"
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
class TestDaemonKitConfig < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_initialize_with_env_hash
|
6
|
+
data = {
|
7
|
+
'test' => {
|
8
|
+
'foo' => 'bar'
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
config = DaemonKit::Config.new( data )
|
13
|
+
|
14
|
+
assert_equal config['foo'], 'bar'
|
15
|
+
assert_equal config.foo, 'bar'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_initialize_without_env_hash
|
19
|
+
data = {
|
20
|
+
'foo' => 'bar'
|
21
|
+
}
|
22
|
+
|
23
|
+
config = DaemonKit::Config.new( data )
|
24
|
+
|
25
|
+
assert_equal config['foo'], 'bar'
|
26
|
+
assert_equal config.foo, 'bar'
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestDeployCapistranoGenerator < Test::Unit::TestCase
|
5
|
+
include RubiGen::GeneratorTestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
bare_setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
bare_teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
# Some generator-related assertions:
|
16
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
+
# assert_directory_exists(name)
|
18
|
+
# assert_generated_class(name, &block)
|
19
|
+
# assert_generated_module(name, &block)
|
20
|
+
# assert_generated_test_for(name, &block)
|
21
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
+
#
|
24
|
+
# Other helper methods are:
|
25
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
+
|
29
|
+
def test_generator_without_options
|
30
|
+
run_generator('deploy_capistrano', ['myapp'], sources)
|
31
|
+
assert_generated_file "Capfile"
|
32
|
+
assert_directory_exists "config"
|
33
|
+
assert_generated_file "config/deploy.rb"
|
34
|
+
assert_directory_exists "config/deploy"
|
35
|
+
assert_generated_file "config/deploy/staging.rb"
|
36
|
+
assert_generated_file "config/deploy/production.rb"
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def sources
|
41
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
def generator_path
|
46
|
+
"daemon_generators"
|
47
|
+
end
|
48
|
+
end
|