apphunkd 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +18 -0
  5. data/Rakefile +78 -0
  6. data/TODO +1 -0
  7. data/VERSION +1 -0
  8. data/apphunkd.gemspec +258 -0
  9. data/bin/apphunkd +4 -0
  10. data/config/arguments.rb +12 -0
  11. data/config/boot.rb +68 -0
  12. data/config/environment.rb +23 -0
  13. data/config/environments/development.rb +2 -0
  14. data/config/environments/production.rb +2 -0
  15. data/config/environments/test.rb +2 -0
  16. data/config/post-daemonize/readme +5 -0
  17. data/config/pre-daemonize/readme +12 -0
  18. data/config/pre-daemonize/requires.rb +2 -0
  19. data/lib/apphunkd.rb +25 -0
  20. data/lib/apphunkd/api.rb +5 -0
  21. data/lib/apphunkd/api/service.rb +27 -0
  22. data/lib/apphunkd/queue.rb +96 -0
  23. data/lib/apphunkd/remote.rb +29 -0
  24. data/lib/apphunkd/remote/result.rb +15 -0
  25. data/libexec/apphunkd-daemon.rb +13 -0
  26. data/script/console +3 -0
  27. data/script/destroy +14 -0
  28. data/script/generate +14 -0
  29. data/spec/lib/apphunkd/api/service_spec.rb +47 -0
  30. data/spec/lib/apphunkd/queue_spec.rb +129 -0
  31. data/spec/lib/apphunkd/remote_spec.rb +61 -0
  32. data/spec/lib/apphunkd_spec.rb +50 -0
  33. data/spec/spec.opts +1 -0
  34. data/spec/spec_helper.rb +13 -0
  35. data/support/apphunkd.initd +47 -0
  36. data/support/apphunkd.monitrc +3 -0
  37. data/tasks/rspec.rake +21 -0
  38. data/vendor/daemon-kit/Configuration.txt +102 -0
  39. data/vendor/daemon-kit/Deployment.txt +113 -0
  40. data/vendor/daemon-kit/History.txt +97 -0
  41. data/vendor/daemon-kit/Logging.txt +92 -0
  42. data/vendor/daemon-kit/Manifest.txt +166 -0
  43. data/vendor/daemon-kit/PostInstall.txt +6 -0
  44. data/vendor/daemon-kit/README.rdoc +130 -0
  45. data/vendor/daemon-kit/Rakefile +37 -0
  46. data/vendor/daemon-kit/RuoteParticipants.txt +113 -0
  47. data/vendor/daemon-kit/TODO.txt +37 -0
  48. data/vendor/daemon-kit/app_generators/daemon_kit/USAGE +7 -0
  49. data/vendor/daemon-kit/app_generators/daemon_kit/daemon_kit_generator.rb +161 -0
  50. data/vendor/daemon-kit/app_generators/daemon_kit/templates/README +48 -0
  51. data/vendor/daemon-kit/app_generators/daemon_kit/templates/Rakefile +6 -0
  52. data/vendor/daemon-kit/app_generators/daemon_kit/templates/bin/daemon.erb +7 -0
  53. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/arguments.rb +12 -0
  54. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/boot.rb +68 -0
  55. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environment.rb +23 -0
  56. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/development.rb +2 -0
  57. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/production.rb +2 -0
  58. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/test.rb +2 -0
  59. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/post-daemonize/readme +5 -0
  60. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/pre-daemonize/readme +12 -0
  61. data/vendor/daemon-kit/app_generators/daemon_kit/templates/lib/daemon.rb +2 -0
  62. data/vendor/daemon-kit/app_generators/daemon_kit/templates/libexec/daemon.erb +18 -0
  63. data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/console +3 -0
  64. data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/destroy +14 -0
  65. data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/generate +14 -0
  66. data/vendor/daemon-kit/bin/daemon_kit +18 -0
  67. data/vendor/daemon-kit/daemon_generators/amqp/USAGE +5 -0
  68. data/vendor/daemon-kit/daemon_generators/amqp/amqp_generator.rb +65 -0
  69. data/vendor/daemon-kit/daemon_generators/amqp/templates/config/amqp.yml +28 -0
  70. data/vendor/daemon-kit/daemon_generators/amqp/templates/config/initializers/amqp.rb +7 -0
  71. data/vendor/daemon-kit/daemon_generators/amqp/templates/libexec/daemon.rb +37 -0
  72. data/vendor/daemon-kit/daemon_generators/cron/USAGE +5 -0
  73. data/vendor/daemon-kit/daemon_generators/cron/cron_generator.rb +64 -0
  74. data/vendor/daemon-kit/daemon_generators/cron/templates/config/initializers/cron.rb +11 -0
  75. data/vendor/daemon-kit/daemon_generators/cron/templates/libexec/daemon.rb +43 -0
  76. data/vendor/daemon-kit/daemon_generators/cucumber/USAGE +11 -0
  77. data/vendor/daemon-kit/daemon_generators/cucumber/cucumber_generator.rb +38 -0
  78. data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber +8 -0
  79. data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber.rake +13 -0
  80. data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber_environment.rb +2 -0
  81. data/vendor/daemon-kit/daemon_generators/cucumber/templates/env.rb +7 -0
  82. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +35 -0
  83. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/Capfile +10 -0
  84. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/USAGE +10 -0
  85. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy.rb +53 -0
  86. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +6 -0
  87. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +6 -0
  88. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/environments/staging.rb +0 -0
  89. data/vendor/daemon-kit/daemon_generators/jabber/USAGE +5 -0
  90. data/vendor/daemon-kit/daemon_generators/jabber/jabber_generator.rb +65 -0
  91. data/vendor/daemon-kit/daemon_generators/jabber/templates/config/initializers/jabber.rb +7 -0
  92. data/vendor/daemon-kit/daemon_generators/jabber/templates/config/jabber.yml +26 -0
  93. data/vendor/daemon-kit/daemon_generators/jabber/templates/libexec/daemon.rb +27 -0
  94. data/vendor/daemon-kit/daemon_generators/nanite_agent/USAGE +5 -0
  95. data/vendor/daemon-kit/daemon_generators/nanite_agent/nanite_agent_generator.rb +68 -0
  96. data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/config/initializers/nanite_agent.rb +6 -0
  97. data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/config/nanite.yml +35 -0
  98. data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/lib/actors/sample.rb +11 -0
  99. data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/libexec/daemon.rb +31 -0
  100. data/vendor/daemon-kit/daemon_generators/rspec/USAGE +5 -0
  101. data/vendor/daemon-kit/daemon_generators/rspec/rspec_generator.rb +55 -0
  102. data/vendor/daemon-kit/daemon_generators/rspec/templates/spec.rb +11 -0
  103. data/vendor/daemon-kit/daemon_generators/rspec/templates/spec/spec.opts +1 -0
  104. data/vendor/daemon-kit/daemon_generators/rspec/templates/spec/spec_helper.rb +21 -0
  105. data/vendor/daemon-kit/daemon_generators/rspec/templates/tasks/rspec.rake +21 -0
  106. data/vendor/daemon-kit/daemon_generators/ruote/USAGE +5 -0
  107. data/vendor/daemon-kit/daemon_generators/ruote/ruote_generator.rb +67 -0
  108. data/vendor/daemon-kit/daemon_generators/ruote/templates/config/amqp.yml +30 -0
  109. data/vendor/daemon-kit/daemon_generators/ruote/templates/config/initializers/ruote.rb +13 -0
  110. data/vendor/daemon-kit/daemon_generators/ruote/templates/config/ruote.yml +23 -0
  111. data/vendor/daemon-kit/daemon_generators/ruote/templates/lib/daemon.rb +4 -0
  112. data/vendor/daemon-kit/daemon_generators/ruote/templates/lib/sample.rb +26 -0
  113. data/vendor/daemon-kit/daemon_generators/ruote/templates/libexec/daemon.rb +33 -0
  114. data/vendor/daemon-kit/lib/daemon_kit.rb +54 -0
  115. data/vendor/daemon-kit/lib/daemon_kit/abstract_logger.rb +235 -0
  116. data/vendor/daemon-kit/lib/daemon_kit/amqp.rb +38 -0
  117. data/vendor/daemon-kit/lib/daemon_kit/application.rb +187 -0
  118. data/vendor/daemon-kit/lib/daemon_kit/arguments.rb +165 -0
  119. data/vendor/daemon-kit/lib/daemon_kit/commands/console.rb +38 -0
  120. data/vendor/daemon-kit/lib/daemon_kit/config.rb +108 -0
  121. data/vendor/daemon-kit/lib/daemon_kit/console_daemon.rb +2 -0
  122. data/vendor/daemon-kit/lib/daemon_kit/core_ext.rb +1 -0
  123. data/vendor/daemon-kit/lib/daemon_kit/core_ext/configurable.rb +96 -0
  124. data/vendor/daemon-kit/lib/daemon_kit/core_ext/string.rb +22 -0
  125. data/vendor/daemon-kit/lib/daemon_kit/cron.rb +48 -0
  126. data/vendor/daemon-kit/lib/daemon_kit/cucumber/world.rb +38 -0
  127. data/vendor/daemon-kit/lib/daemon_kit/deployment/capistrano.rb +482 -0
  128. data/vendor/daemon-kit/lib/daemon_kit/em.rb +43 -0
  129. data/vendor/daemon-kit/lib/daemon_kit/error_handlers/base.rb +32 -0
  130. data/vendor/daemon-kit/lib/daemon_kit/error_handlers/hoptoad.rb +61 -0
  131. data/vendor/daemon-kit/lib/daemon_kit/error_handlers/mail.rb +85 -0
  132. data/vendor/daemon-kit/lib/daemon_kit/exceptions.rb +8 -0
  133. data/vendor/daemon-kit/lib/daemon_kit/initializer.rb +438 -0
  134. data/vendor/daemon-kit/lib/daemon_kit/jabber.rb +170 -0
  135. data/vendor/daemon-kit/lib/daemon_kit/nanite.rb +7 -0
  136. data/vendor/daemon-kit/lib/daemon_kit/nanite/agent.rb +56 -0
  137. data/vendor/daemon-kit/lib/daemon_kit/pid_file.rb +61 -0
  138. data/vendor/daemon-kit/lib/daemon_kit/ruote_participants.rb +119 -0
  139. data/vendor/daemon-kit/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
  140. data/vendor/daemon-kit/lib/daemon_kit/ruote_workitem.rb +169 -0
  141. data/vendor/daemon-kit/lib/daemon_kit/safety.rb +85 -0
  142. data/vendor/daemon-kit/lib/daemon_kit/tasks.rb +2 -0
  143. data/vendor/daemon-kit/lib/daemon_kit/tasks/environment.rake +10 -0
  144. data/vendor/daemon-kit/lib/daemon_kit/tasks/framework.rake +120 -0
  145. data/vendor/daemon-kit/lib/daemon_kit/tasks/god.rake +62 -0
  146. data/vendor/daemon-kit/lib/daemon_kit/tasks/log.rake +8 -0
  147. data/vendor/daemon-kit/lib/daemon_kit/tasks/monit.rake +29 -0
  148. data/vendor/daemon-kit/script/console +10 -0
  149. data/vendor/daemon-kit/script/destroy +14 -0
  150. data/vendor/daemon-kit/script/generate +14 -0
  151. data/vendor/daemon-kit/script/txt2html +71 -0
  152. data/vendor/daemon-kit/spec/abstract_logger_spec.rb +126 -0
  153. data/vendor/daemon-kit/spec/argument_spec.rb +70 -0
  154. data/vendor/daemon-kit/spec/config_spec.rb +79 -0
  155. data/vendor/daemon-kit/spec/configurable_spec.rb +56 -0
  156. data/vendor/daemon-kit/spec/daemon_kit_spec.rb +7 -0
  157. data/vendor/daemon-kit/spec/error_handlers_spec.rb +23 -0
  158. data/vendor/daemon-kit/spec/fixtures/env.yml +15 -0
  159. data/vendor/daemon-kit/spec/fixtures/noenv.yml +4 -0
  160. data/vendor/daemon-kit/spec/initializer_spec.rb +26 -0
  161. data/vendor/daemon-kit/spec/spec.opts +1 -0
  162. data/vendor/daemon-kit/spec/spec_helper.rb +27 -0
  163. data/vendor/daemon-kit/tasks/rspec.rake +21 -0
  164. data/vendor/daemon-kit/templates/god/god.erb +69 -0
  165. data/vendor/daemon-kit/templates/monit/monit.erb +14 -0
  166. data/vendor/daemon-kit/test/test_amqp_generator.rb +48 -0
  167. data/vendor/daemon-kit/test/test_cron_generator.rb +45 -0
  168. data/vendor/daemon-kit/test/test_daemon-kit_generator.rb +84 -0
  169. data/vendor/daemon-kit/test/test_daemon_kit_config.rb +28 -0
  170. data/vendor/daemon-kit/test/test_deploy_capistrano_generator.rb +48 -0
  171. data/vendor/daemon-kit/test/test_generator_helper.rb +29 -0
  172. data/vendor/daemon-kit/test/test_helper.rb +7 -0
  173. data/vendor/daemon-kit/test/test_jabber_generator.rb +49 -0
  174. data/vendor/daemon-kit/test/test_nanite_agent_generator.rb +49 -0
  175. data/vendor/daemon-kit/test/test_ruote_generator.rb +45 -0
  176. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail.rb +5 -0
  177. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/address.rb +426 -0
  178. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/attachments.rb +46 -0
  179. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/base64.rb +46 -0
  180. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/compat.rb +41 -0
  181. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/config.rb +67 -0
  182. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/core_extensions.rb +63 -0
  183. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/encode.rb +581 -0
  184. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/header.rb +960 -0
  185. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/index.rb +9 -0
  186. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/interface.rb +1130 -0
  187. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/loader.rb +3 -0
  188. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mail.rb +578 -0
  189. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mailbox.rb +495 -0
  190. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/main.rb +6 -0
  191. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mbox.rb +3 -0
  192. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/net.rb +248 -0
  193. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/obsolete.rb +132 -0
  194. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/parser.rb +1476 -0
  195. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/port.rb +379 -0
  196. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/quoting.rb +118 -0
  197. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
  198. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/scanner.rb +49 -0
  199. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/scanner_r.rb +261 -0
  200. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/stringio.rb +280 -0
  201. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/utils.rb +337 -0
  202. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/version.rb +39 -0
  203. data/vendor/daemon-kit/vendor/tmail.rb +13 -0
  204. metadata +281 -0
@@ -0,0 +1,61 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Apphunkd::Remote do
4
+ before(:each) do
5
+ @remote = Apphunkd::Remote
6
+ @mock_uri = mock('URI', :path => '/home', :user => nil, :host => 'localhost', :port => 80)
7
+ URI.stub!(:parse).and_return(@mock_uri)
8
+ Net::HTTP.stub!(:post_form)
9
+ end
10
+
11
+ it 'should parse the url' do
12
+ URI.should_receive(:parse).with('http://example.org').and_return(@mock_uri)
13
+ @remote.post('http://example.org')
14
+ end
15
+
16
+ it 'should send the payload to a specified parsed uri' do
17
+ Net::HTTP.should_receive(:post_form).with(@mock_uri, { :value => 'home' })
18
+ @remote.post('http://example.org', { :value => 'home' })
19
+ end
20
+
21
+ context 'timeout' do
22
+ it 'should wrap the post in a default Timeout of 30 seconds' do
23
+ Timeout.should_receive(:timeout).with(30)
24
+ @remote.post('http://example.org', { :value => 'home' })
25
+ end
26
+
27
+ it 'should accept a timeout as additional argument' do
28
+ Timeout.should_receive(:timeout).with(50)
29
+ @remote.post('http://example.org', { :value => 'home' }, 50)
30
+ end
31
+ end
32
+
33
+ context 'result' do
34
+ before(:each) do
35
+ @mock_net_response = mock('Net::HTTPResponse', :code => 200)
36
+ Net::HTTP.stub!(:post_form).and_return(@mock_net_response)
37
+ end
38
+
39
+ it 'should return status :timeout if the time run out' do
40
+ Timeout.should_receive(:timeout).and_raise(Timeout::Error)
41
+ result = @remote.post('http://example.org', { :value => 'home' }, 0)
42
+ result.status.should == :timeout
43
+ end
44
+
45
+ it 'should return status :connection_error if the connection failed' do
46
+ Net::HTTP.should_receive(:post_form).and_raise(SocketError)
47
+ result = @remote.post('http://example.org', { :value => 'home' }, 0)
48
+ result.status.should == :connection_error
49
+ end
50
+
51
+ it 'should return the status code' do
52
+ result = @remote.post('http://example.org', { :value => 'home' }, 0)
53
+ result.status.should == :ok
54
+ end
55
+
56
+ it 'should return the original response' do
57
+ result = @remote.post('http://example.org', { :value => 'home' }, 0)
58
+ result.response == @mock_net_response
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,50 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Apphunkd do
4
+ describe "#run!" do
5
+ before(:each) do
6
+ Apphunkd.stub!(:initialize_queue)
7
+ Apphunkd.stub!(:initialize_api_service)
8
+ end
9
+
10
+ it "should initialize the queue" do
11
+ Apphunkd.should_receive(:initialize_queue)
12
+ Apphunkd.run!
13
+ end
14
+
15
+ it "should initialize the api service" do
16
+ Apphunkd.should_receive(:initialize_api_service)
17
+ Apphunkd.run!
18
+ end
19
+ end
20
+
21
+ describe "#initialize_queue" do
22
+ before(:each) do
23
+ @queue = mock('Queue instance')
24
+ Apphunkd::Queue.stub!(:new).and_return(@queue)
25
+ end
26
+
27
+ it "should create and assign a new Queue instance" do
28
+ @queue.stub!(:activate!)
29
+ Apphunkd.initialize_queue
30
+ Apphunkd.queue.should eql(@queue)
31
+ end
32
+
33
+ it 'activate the queue' do
34
+ @queue.should_receive(:activate!)
35
+ Apphunkd.initialize_queue
36
+ end
37
+ end
38
+
39
+ describe '#initialize_api_service' do
40
+ it 'should start the api service' do
41
+ Apphunkd::API::Service.should_receive(:run!)
42
+ Apphunkd.initialize_api_service
43
+ end
44
+
45
+ it 'should start on 127.0.0.1:8212' do
46
+ Apphunkd::API::Service.should_receive(:run!).with(:port => '8212', :host => '127.0.0.1')
47
+ Apphunkd.initialize_api_service
48
+ end
49
+ end
50
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ require File.dirname(__FILE__) + '/../config/environment'
10
+ DaemonKit::Application.running!
11
+
12
+ Spec::Runner.configure do |config|
13
+ end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # apphunkd Startup script for apphunkd by Andreas Wolff
4
+ #
5
+ # description: apphunkd is a daemon for sending messages from your applications to apphunk.com
6
+ #
7
+
8
+ def start
9
+ puts "Starting.."
10
+ `apphunkd start -e production`
11
+ end
12
+
13
+ def stop
14
+ puts "Stopping.."
15
+ `apphunkd stop -e production`
16
+ end
17
+
18
+ def restart
19
+ stop
20
+ start
21
+ end
22
+
23
+ def status
24
+ if File.exist?('/var/run/apphunkd.pid')
25
+ pid = File.readlines('/var/run/apphunkd.pid')[0].chomp
26
+ puts "apphunkd running (#{pid}).."
27
+ else
28
+ puts "apphunkd not running.."
29
+ end
30
+ end
31
+
32
+
33
+ unless ['start', 'stop', 'restart', 'status'].include? ARGV.first
34
+ puts "Usage: apphunkd {start|stop|restart|status}"
35
+ exit
36
+ end
37
+
38
+ case
39
+ when ARGV.include?('start')
40
+ start
41
+ when ARGV.include?('stop')
42
+ stop
43
+ when ARGV.include?('restart')
44
+ restart
45
+ when ARGV.include?('status')
46
+ status
47
+ end
@@ -0,0 +1,3 @@
1
+ check process apphunkd with pidfile /var/run/apphunkd.pid
2
+ start program = "/etc/init.d/apphunkd start"
3
+ stop program = "/etc/init.d/apphunkd stop"
data/tasks/rspec.rake ADDED
@@ -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/"
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,102 @@
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
+ -l path (or --log path) to set the path for the log file
33
+ -v shows the DaemonKit version
34
+ -h shows a useful help message
35
+
36
+ === Custom arguments
37
+
38
+ It is possible for you to specify your own arguments as well, by
39
+ updating the <em>config/arguments.rb</em> file. This file is eval'd
40
+ inside #DaemonKit::Arguments and gives you access to the following two
41
+ variables:
42
+
43
+ * opts - Instance of OptionParser[http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html]
44
+ * @options - A standard Ruby hash that you can populate and access later
45
+
46
+ Your custom arguments can be accessed like this:
47
+
48
+ DaemonKit.arguments.options
49
+
50
+ === Advanced Configuration
51
+
52
+ All the writable attributes of the default #DaemonKit::Configuration
53
+ instance call also be modified from the command line using the special
54
+ <em>--config</em> arguments:
55
+
56
+ --config force_kill_wait=30
57
+
58
+ This happens after <em>config/environment.rb</em> is processed, so all
59
+ command line arguments will overwrite those values.
60
+
61
+ === Daemon umask
62
+
63
+ By default daemon processes run with a umask of 022, but this can be changed
64
+ on the command line or in +config/environment.rb+.
65
+
66
+ To set a more restrictive umask via command line arguments, you can start your
67
+ daemon like this:
68
+
69
+ $ ./bin/daemon start --config umask=0077
70
+
71
+ Or the same in +config/environment.rb+
72
+
73
+ DaemonKit::Initializer.run do |config|
74
+ # ...
75
+
76
+ # restrictive umask
77
+ config.umask = 0077
78
+
79
+ # ...
80
+ end
81
+
82
+ === Privilege Separation
83
+
84
+ By default daemon processes run as the user that starts them, inheriting all
85
+ their privileges (or lack thereof). Getting daemon-kit to drop privileges
86
+ can currently only be done using command-line parameters, and only works
87
+ reliable on *nix (OSX seemed cranky at the time of testing).
88
+
89
+ $ ./bin/daemon start --config user=nobody --config group=nobody
90
+
91
+ Privileges are dropped at the earliest possible phase of starting the daemon.
92
+
93
+ Things to note on privilege separation:
94
+
95
+ * You generally have to be root to be able to perform this
96
+ * File system permissions for +log/+ needs to be correct
97
+ * Daemon-kit will only shed privileges on the +start+ command, not on +run+
98
+ * Make sure your code is secure if accepting stuff from the outside world
99
+
100
+ The implementation stems from the advice given by Joe Damato on his blog post
101
+ http://timetobleed.com/tag/privilege-escalation/
102
+
@@ -0,0 +1,113 @@
1
+ = Deploying your daemons
2
+
3
+ daemon-kit provides built-in support for
4
+ Capistrano[http://www.capify.org] deployments, using a customized
5
+ version of the standard 'deploy' recipe for Ruby on Rails
6
+ applications.
7
+
8
+ User of Vlad[http://hitsquad.rubyforge.org/vlad/]? Get in touch so we
9
+ can discuss your contribution to daemon-kit ;)
10
+
11
+ == Generating capistrano configurations
12
+
13
+ When generating a new daemon, you can pass the <em>-d capistrano</em>
14
+ argument to the <em>daemon_kit</em> command. In case you already have
15
+ a generated daemon, run the following command inside your project:
16
+
17
+ $ ruby script/generate deploy_capistrano
18
+
19
+ == Overview of generated configurations
20
+
21
+ The generator creates the following files worth noticing:
22
+
23
+ config/deploy.rb
24
+ config/deploy/*.rb
25
+
26
+ The generator also creates a new environment for you, a
27
+ <em>staging</em> environment. Useful for testing your deployments
28
+ before taking anything into production.
29
+
30
+ == Configuring capistrano
31
+
32
+ For each environment (staging & production) you only need to specify
33
+ the target hosts in <em>config/deploy/(staging|production).rb</em>.
34
+
35
+ Each of the stub files have example configuration values you can just
36
+ edit.
37
+
38
+ The rest of your configuration generally occurs in
39
+ <em>config/deploy.rb</em>.
40
+
41
+ Everything works exactly like standard capistrano, with the exception
42
+ of the following directives:
43
+
44
+ * :config_files
45
+ * :shared_children
46
+
47
+ === :config_files
48
+
49
+ Since the daemon configuration files will almost always differ between
50
+ your development environment and your staging/production environment,
51
+ the deployment recipe makes adequate provision for this.
52
+
53
+ Use the :config_files directive to set an array of file names from the
54
+ <em>config</em> directory that you want replaced with production
55
+ configuration files found on the server:
56
+
57
+ set :config_files, %w{ amqp.yaml }
58
+
59
+ On your target server, in the <em>:deploy_to</em> folder, create a
60
+ <em>config</em> directory and place your configuration files in
61
+ there. One each deploy, capistrano will rename the files in your
62
+ deployed configuration directory with a <em>.orig</em> extension, and copy
63
+ the files from <em>:deploy_to/config</em> into the newly deployed
64
+ release.
65
+
66
+ This makes it easy to keep production configurations out of your
67
+ working directories or version control systems.
68
+
69
+ === :shared_children
70
+
71
+ The original capistrano recipe that daemon-kit's recipe is built from
72
+ provided support for tracking shared directories between
73
+ deployments. This works by removing the deployed directory, and
74
+ creating a symlink from <em>:deploy_to/shared/</em> into the correct
75
+ location within the deployed release.
76
+
77
+ You specify your list of directories with the
78
+ <em>:shared_children</em>, each being relative to the DAEMON_ROOT.
79
+
80
+ set :shared_children, %w{ log }
81
+
82
+ The daemon-kit deployment recipe makes no assumptions on shared
83
+ directories, and gives you full control. The default only includes the
84
+ log directory, which you can remove if you want separate log
85
+ directories for each deployed release.
86
+
87
+ == Remote dependencies
88
+
89
+ By default, the deployment configuration file is configured to check
90
+ the remote dependencies before updating the code on the target
91
+ host. You can disable this behaviour by commenting out the following
92
+ line:
93
+
94
+ before "deploy:update_code", "deploy:check"
95
+
96
+ The only default remote dependency is the daemon-kit gem, and it will
97
+ check for the same version you currently have installed (or a later
98
+ one).
99
+
100
+ == More capistrano resources
101
+
102
+ To see a list of available commands, please run the following command
103
+ in the root of your project:
104
+
105
+ $ cap -vT
106
+
107
+ For more information on capistrano, please refer to the following list
108
+ of online resources:
109
+
110
+ * Capistrano Website[http://www.capify.org]
111
+ * Capistrano Wiki[http://wiki.capify.org]
112
+ * Capistrano Group[http://groups.google.com/group/capistrano]
113
+ * #capistrano on Freenode
@@ -0,0 +1,97 @@
1
+ == 0.1.7.10 (WIP)
2
+
3
+ * Ruote remote participants
4
+ * Allow process umask to be configured, defaults to 022
5
+ * Updates to DaemonKit::Config hashes
6
+ * Fixed argument parsing bug (reported by Mathijs Kwik (bluescreen303)
7
+ * Support for privilege separation (See Configuration.txt)
8
+
9
+ == 0.1.7.9 2009-06-22
10
+
11
+ * Backtraces only logged on unclean shutdown
12
+ * AMQP generator got new keep alive code
13
+
14
+ == 0.1.7.8 2009-06-22
15
+
16
+ * Optional logging of all exceptions when the daemon process dies
17
+ unexpectedly
18
+ * Update generated environment.rb to reflect new backtraces option
19
+
20
+ == 0.1.7.7 2009-06-22
21
+
22
+ * Fixed compatibility with rufus-scheduler-2.0.0 (or newer) in cron
23
+ generator
24
+ * Started central eventmachine reactor management code
25
+ * Now depends on eventmachine
26
+
27
+ == 0.1.7.6 (Not released)
28
+
29
+ * Support for cucumber
30
+ * Fixed issue in daemon_kit:upgrade task
31
+ * Moved rspec generator into new home
32
+ * Removed conflicting rubigen generator, messed with our script directory
33
+ * Fixed bug where environment.rb overwrites some --config values (reported by Josh Owens)
34
+
35
+ == 0.1.7.5 2009-06-08
36
+
37
+ * New AbstractLogger
38
+ ** Default Logger backend
39
+ ** SysLogLogger support
40
+ * More documentation
41
+
42
+ == 0.1.7.4 2009-06-05
43
+
44
+ * Fixed bug with control script generator (thanks Sho Fukamachi)
45
+ * Enhanced deploy.rb template to check for current dk gem verion,
46
+ unless vendored
47
+ * Fix bug in capistrano recipe for restarting daemons
48
+ * Added log:truncate rake task
49
+ * Error mails now handled by TMail
50
+
51
+ == 0.1.7.3 2009-05-31
52
+
53
+ * Removed dependency on daemons gem, now handled in house
54
+ * New argument management
55
+ * Some more docs
56
+
57
+ == 0.1.7.1 2009-05-28
58
+
59
+ * Fixed some minor issue with Capistrano support
60
+ * Added support for generating dog/monit configuration files via rake
61
+ * Initial implementation of ./script/* utilities
62
+
63
+ == 0.1.7 2009-05-26
64
+
65
+ * Capistrano deployment support
66
+
67
+ == 0.1.6 2009-05-13
68
+
69
+ * DaemonKit::Safety class to handle the trapping and logging of
70
+ exceptions, as well as email notifications or Hoptoad notifications.
71
+ * New config/pre-daemonize and config/post-daemonize structure
72
+ * New tasks to simplify upgrading daemon-kit projects
73
+ * Fixed some other annoyances and bugs
74
+ * Bigger TODO list
75
+
76
+ == 0.1.5 2009-05-07
77
+
78
+ * DaemonKit::Config class to easy the use of YAML configs internally,
79
+ and in generated daemons
80
+
81
+ == 0.1.2 2009-04-28
82
+
83
+ * Added missing rubigen dependency
84
+
85
+ == 0.1.1 2009-04-27
86
+
87
+ * AMQP consumer generator added
88
+ * 'cron' style generator added
89
+ * Allow configuring dir_mode and dir (pid file location) (Jim Lindley)
90
+
91
+ == 0.1.0 2009-01-08
92
+
93
+ * Ability to freeze the gem/edge copies of DaemonKit
94
+ * Simple non-evented Jabber generator
95
+ * Flexible UNIX signal trapping configuration
96
+ * Basic generator completed
97
+ * 1 small step for man, 1 giant leap for mankind