queso-daemon-kit 0.1.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. data/Configuration.txt +110 -0
  2. data/Deployment.txt +113 -0
  3. data/History.txt +97 -0
  4. data/Logging.txt +92 -0
  5. data/Manifest.txt +166 -0
  6. data/PostInstall.txt +6 -0
  7. data/README.rdoc +130 -0
  8. data/Rakefile +37 -0
  9. data/RuoteParticipants.txt +113 -0
  10. data/TODO.txt +37 -0
  11. data/app_generators/daemon_kit/USAGE +7 -0
  12. data/app_generators/daemon_kit/daemon_kit_generator.rb +161 -0
  13. data/app_generators/daemon_kit/templates/README +48 -0
  14. data/app_generators/daemon_kit/templates/Rakefile +6 -0
  15. data/app_generators/daemon_kit/templates/bin/daemon.erb +7 -0
  16. data/app_generators/daemon_kit/templates/config/arguments.rb +12 -0
  17. data/app_generators/daemon_kit/templates/config/boot.rb +68 -0
  18. data/app_generators/daemon_kit/templates/config/environment.rb +23 -0
  19. data/app_generators/daemon_kit/templates/config/environments/development.rb +2 -0
  20. data/app_generators/daemon_kit/templates/config/environments/production.rb +2 -0
  21. data/app_generators/daemon_kit/templates/config/environments/test.rb +2 -0
  22. data/app_generators/daemon_kit/templates/config/post-daemonize/readme +5 -0
  23. data/app_generators/daemon_kit/templates/config/pre-daemonize/readme +12 -0
  24. data/app_generators/daemon_kit/templates/lib/daemon.rb +2 -0
  25. data/app_generators/daemon_kit/templates/libexec/daemon.erb +18 -0
  26. data/app_generators/daemon_kit/templates/script/console +3 -0
  27. data/app_generators/daemon_kit/templates/script/destroy +14 -0
  28. data/app_generators/daemon_kit/templates/script/generate +14 -0
  29. data/bin/daemon_kit +18 -0
  30. data/daemon_generators/amqp/USAGE +5 -0
  31. data/daemon_generators/amqp/amqp_generator.rb +65 -0
  32. data/daemon_generators/amqp/templates/config/amqp.yml +28 -0
  33. data/daemon_generators/amqp/templates/config/initializers/amqp.rb +7 -0
  34. data/daemon_generators/amqp/templates/libexec/daemon.rb +37 -0
  35. data/daemon_generators/cron/USAGE +5 -0
  36. data/daemon_generators/cron/cron_generator.rb +64 -0
  37. data/daemon_generators/cron/templates/config/initializers/cron.rb +11 -0
  38. data/daemon_generators/cron/templates/libexec/daemon.rb +43 -0
  39. data/daemon_generators/cucumber/USAGE +11 -0
  40. data/daemon_generators/cucumber/cucumber_generator.rb +38 -0
  41. data/daemon_generators/cucumber/templates/cucumber +8 -0
  42. data/daemon_generators/cucumber/templates/cucumber.rake +13 -0
  43. data/daemon_generators/cucumber/templates/cucumber_environment.rb +2 -0
  44. data/daemon_generators/cucumber/templates/env.rb +7 -0
  45. data/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +35 -0
  46. data/daemon_generators/deploy_capistrano/templates/Capfile +10 -0
  47. data/daemon_generators/deploy_capistrano/templates/USAGE +10 -0
  48. data/daemon_generators/deploy_capistrano/templates/config/deploy.rb +53 -0
  49. data/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +6 -0
  50. data/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +6 -0
  51. data/daemon_generators/deploy_capistrano/templates/config/environments/staging.rb +0 -0
  52. data/daemon_generators/jabber/USAGE +5 -0
  53. data/daemon_generators/jabber/jabber_generator.rb +65 -0
  54. data/daemon_generators/jabber/templates/config/initializers/jabber.rb +7 -0
  55. data/daemon_generators/jabber/templates/config/jabber.yml +26 -0
  56. data/daemon_generators/jabber/templates/libexec/daemon.rb +27 -0
  57. data/daemon_generators/nanite_agent/USAGE +5 -0
  58. data/daemon_generators/nanite_agent/nanite_agent_generator.rb +68 -0
  59. data/daemon_generators/nanite_agent/templates/config/initializers/nanite_agent.rb +6 -0
  60. data/daemon_generators/nanite_agent/templates/config/nanite.yml +35 -0
  61. data/daemon_generators/nanite_agent/templates/lib/actors/sample.rb +11 -0
  62. data/daemon_generators/nanite_agent/templates/libexec/daemon.rb +31 -0
  63. data/daemon_generators/rspec/USAGE +5 -0
  64. data/daemon_generators/rspec/rspec_generator.rb +55 -0
  65. data/daemon_generators/rspec/templates/spec.rb +11 -0
  66. data/daemon_generators/rspec/templates/spec/spec.opts +1 -0
  67. data/daemon_generators/rspec/templates/spec/spec_helper.rb +21 -0
  68. data/daemon_generators/rspec/templates/tasks/rspec.rake +21 -0
  69. data/daemon_generators/ruote/USAGE +5 -0
  70. data/daemon_generators/ruote/ruote_generator.rb +67 -0
  71. data/daemon_generators/ruote/templates/config/amqp.yml +30 -0
  72. data/daemon_generators/ruote/templates/config/initializers/ruote.rb +13 -0
  73. data/daemon_generators/ruote/templates/config/ruote.yml +23 -0
  74. data/daemon_generators/ruote/templates/lib/daemon.rb +4 -0
  75. data/daemon_generators/ruote/templates/lib/sample.rb +26 -0
  76. data/daemon_generators/ruote/templates/libexec/daemon.rb +33 -0
  77. data/lib/daemon_kit.rb +62 -0
  78. data/lib/daemon_kit/abstract_logger.rb +235 -0
  79. data/lib/daemon_kit/amqp.rb +38 -0
  80. data/lib/daemon_kit/application.rb +187 -0
  81. data/lib/daemon_kit/arguments.rb +165 -0
  82. data/lib/daemon_kit/commands/console.rb +38 -0
  83. data/lib/daemon_kit/config.rb +108 -0
  84. data/lib/daemon_kit/console_daemon.rb +2 -0
  85. data/lib/daemon_kit/core_ext.rb +1 -0
  86. data/lib/daemon_kit/core_ext/configurable.rb +96 -0
  87. data/lib/daemon_kit/core_ext/string.rb +22 -0
  88. data/lib/daemon_kit/cron.rb +48 -0
  89. data/lib/daemon_kit/cucumber/world.rb +38 -0
  90. data/lib/daemon_kit/deployment/capistrano.rb +482 -0
  91. data/lib/daemon_kit/em.rb +43 -0
  92. data/lib/daemon_kit/error_handlers/base.rb +32 -0
  93. data/lib/daemon_kit/error_handlers/hoptoad.rb +60 -0
  94. data/lib/daemon_kit/error_handlers/mail.rb +85 -0
  95. data/lib/daemon_kit/exceptions.rb +15 -0
  96. data/lib/daemon_kit/initializer.rb +438 -0
  97. data/lib/daemon_kit/jabber.rb +170 -0
  98. data/lib/daemon_kit/nanite.rb +7 -0
  99. data/lib/daemon_kit/nanite/agent.rb +56 -0
  100. data/lib/daemon_kit/pid_file.rb +61 -0
  101. data/lib/daemon_kit/ruote_participants.rb +119 -0
  102. data/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
  103. data/lib/daemon_kit/ruote_workitem.rb +169 -0
  104. data/lib/daemon_kit/safety.rb +85 -0
  105. data/lib/daemon_kit/tasks.rb +2 -0
  106. data/lib/daemon_kit/tasks/environment.rake +10 -0
  107. data/lib/daemon_kit/tasks/framework.rake +120 -0
  108. data/lib/daemon_kit/tasks/god.rake +62 -0
  109. data/lib/daemon_kit/tasks/log.rake +8 -0
  110. data/lib/daemon_kit/tasks/monit.rake +29 -0
  111. data/script/console +10 -0
  112. data/script/destroy +14 -0
  113. data/script/generate +14 -0
  114. data/script/txt2html +71 -0
  115. data/spec/abstract_logger_spec.rb +126 -0
  116. data/spec/argument_spec.rb +70 -0
  117. data/spec/config_spec.rb +79 -0
  118. data/spec/configurable_spec.rb +56 -0
  119. data/spec/daemon_kit_spec.rb +7 -0
  120. data/spec/error_handlers_spec.rb +23 -0
  121. data/spec/fixtures/env.yml +15 -0
  122. data/spec/fixtures/noenv.yml +4 -0
  123. data/spec/initializer_spec.rb +26 -0
  124. data/spec/spec.opts +1 -0
  125. data/spec/spec_helper.rb +27 -0
  126. data/tasks/rspec.rake +21 -0
  127. data/templates/god/god.erb +69 -0
  128. data/templates/monit/monit.erb +14 -0
  129. data/test/test_amqp_generator.rb +48 -0
  130. data/test/test_cron_generator.rb +45 -0
  131. data/test/test_daemon-kit_generator.rb +84 -0
  132. data/test/test_daemon_kit_config.rb +28 -0
  133. data/test/test_deploy_capistrano_generator.rb +48 -0
  134. data/test/test_generator_helper.rb +29 -0
  135. data/test/test_helper.rb +7 -0
  136. data/test/test_jabber_generator.rb +49 -0
  137. data/test/test_nanite_agent_generator.rb +49 -0
  138. data/test/test_ruote_generator.rb +45 -0
  139. data/vendor/tmail-1.2.3/tmail.rb +5 -0
  140. data/vendor/tmail-1.2.3/tmail/address.rb +426 -0
  141. data/vendor/tmail-1.2.3/tmail/attachments.rb +46 -0
  142. data/vendor/tmail-1.2.3/tmail/base64.rb +46 -0
  143. data/vendor/tmail-1.2.3/tmail/compat.rb +41 -0
  144. data/vendor/tmail-1.2.3/tmail/config.rb +67 -0
  145. data/vendor/tmail-1.2.3/tmail/core_extensions.rb +63 -0
  146. data/vendor/tmail-1.2.3/tmail/encode.rb +581 -0
  147. data/vendor/tmail-1.2.3/tmail/header.rb +960 -0
  148. data/vendor/tmail-1.2.3/tmail/index.rb +9 -0
  149. data/vendor/tmail-1.2.3/tmail/interface.rb +1130 -0
  150. data/vendor/tmail-1.2.3/tmail/loader.rb +3 -0
  151. data/vendor/tmail-1.2.3/tmail/mail.rb +578 -0
  152. data/vendor/tmail-1.2.3/tmail/mailbox.rb +495 -0
  153. data/vendor/tmail-1.2.3/tmail/main.rb +6 -0
  154. data/vendor/tmail-1.2.3/tmail/mbox.rb +3 -0
  155. data/vendor/tmail-1.2.3/tmail/net.rb +248 -0
  156. data/vendor/tmail-1.2.3/tmail/obsolete.rb +132 -0
  157. data/vendor/tmail-1.2.3/tmail/parser.rb +1476 -0
  158. data/vendor/tmail-1.2.3/tmail/port.rb +379 -0
  159. data/vendor/tmail-1.2.3/tmail/quoting.rb +118 -0
  160. data/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
  161. data/vendor/tmail-1.2.3/tmail/scanner.rb +49 -0
  162. data/vendor/tmail-1.2.3/tmail/scanner_r.rb +261 -0
  163. data/vendor/tmail-1.2.3/tmail/stringio.rb +280 -0
  164. data/vendor/tmail-1.2.3/tmail/utils.rb +337 -0
  165. data/vendor/tmail-1.2.3/tmail/version.rb +39 -0
  166. data/vendor/tmail.rb +13 -0
  167. metadata +281 -0
@@ -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,6 @@
1
+ require File.dirname(__FILE__) + '/config/boot'
2
+
3
+ require 'rake'
4
+ require 'daemon_kit/tasks'
5
+
6
+ Dir[File.join(File.dirname(__FILE__), 'tasks/*.rake')].each { |rake| load rake }
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Stub executable for <%= daemon_name %>
4
+
5
+ require File.dirname(__FILE__) + '/../config/environment'
6
+
7
+ DaemonKit::Application.exec( DAEMON_ROOT + '/libexec/<%= daemon_name %>-daemon.rb' )
@@ -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,68 @@
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
+ require 'rubygems'
44
+ gem 'kennethkalmer-daemon-kit'
45
+ require 'daemon_kit/initializer'
46
+ rescue Gem::LoadError
47
+ begin
48
+ gem 'daemon-kit'
49
+ require 'daemon_kit/initializer'
50
+ rescue Gem::LoadError => e
51
+ msg = <<EOF
52
+ You are missing the daemon-kit gem. Please install one of the following gems:
53
+
54
+ * Unstable - sudo gem install kennethkalmer-daemon-kit -s http://gems.github.com/
55
+ * Stable - sudo gem install daemon-kit
56
+
57
+ NOTE: The 'unstable' gem is loaded first, before falling back to the stable gem!
58
+
59
+ EOF
60
+ $stderr.puts msg
61
+ exit 1
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ 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
@@ -0,0 +1,2 @@
1
+ # This is the same context as the environment.rb file, it is only
2
+ # loaded afterwards and only in the development environment
@@ -0,0 +1,2 @@
1
+ # This is the same context as the environment.rb file, it is only
2
+ # loaded afterwards and only in the production environment
@@ -0,0 +1,2 @@
1
+ # This is the same context as the environment.rb file, it is only
2
+ # loaded afterwards and only in the test environment
@@ -0,0 +1,5 @@
1
+ # You can place files in here to be loaded after the code is daemonized.
2
+ #
3
+ # All the files placed here will just be required into the running
4
+ # process. This is the correct place to open any IO objects, establish
5
+ # database connections, etc.
@@ -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,2 @@
1
+ # Your starting point for daemon specific classes. This directory is
2
+ # already included in your load path, so no need to specify it.
@@ -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,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'daemon_kit/commands/console'
@@ -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)
@@ -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/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:daemon]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/bin/daemon_kit ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ if %w(-v --version).include? ARGV.first
7
+ require 'daemon_kit'
8
+ puts "#{File.basename($0)} #{DaemonKit::VERSION}"
9
+ exit(0)
10
+ end
11
+
12
+ require 'rubigen/scripts/generate'
13
+ RubiGen::Base.use_application_sources! :rubygems
14
+ RubiGen::Base.prepend_sources(*[
15
+ RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "app_generators")),
16
+ RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "daemon_generators"))
17
+ ])
18
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'daemon_kit')
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,65 @@
1
+ class AmqpGenerator < RubiGen::Base
2
+
3
+ default_options :author => nil
4
+
5
+ attr_reader :name
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ super
9
+ usage if args.empty?
10
+ @name = args.shift
11
+ extract_options
12
+ end
13
+
14
+ def manifest
15
+ record do |m|
16
+ # Ensure appropriate folder(s) exists
17
+ m.directory ''
18
+
19
+ # Create stubs
20
+ # m.template "template.rb.erb", "some_file_after_erb.rb"
21
+ # m.template_copy_each ["template.rb", "template2.rb"]
22
+ # m.template_copy_each ["template.rb", "template2.rb"], "some/path"
23
+ # m.file "file", "some_file_copied"
24
+ # m.file_copy_each ["path/to/file", "path/to/file2"]
25
+ # m.file_copy_each ["path/to/file", "path/to/file2"], "some/path"
26
+
27
+ # Copy over our configs
28
+ m.directory 'config'
29
+ m.template 'config/amqp.yml', 'config/amqp.yml'
30
+ m.directory 'config/initializers'
31
+ m.template 'config/initializers/amqp.rb', "config/initializers/#{name}.rb"
32
+
33
+ # Copy over our daemon
34
+ m.directory 'libexec'
35
+ m.template 'libexec/daemon.rb', "libexec/#{name}-daemon.rb"
36
+ end
37
+ end
38
+
39
+ protected
40
+ def banner
41
+ <<-EOS
42
+ Creates a ...
43
+
44
+ USAGE: #{$0} #{spec.name} name
45
+ EOS
46
+ end
47
+
48
+ def add_options!(opts)
49
+ # opts.separator ''
50
+ # opts.separator 'Options:'
51
+ # For each option below, place the default
52
+ # at the top of the file next to "default_options"
53
+ # opts.on("-a", "--author=\"Your Name\"", String,
54
+ # "Some comment about this option",
55
+ # "Default: none") { |o| options[:author] = o }
56
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
57
+ end
58
+
59
+ def extract_options
60
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
61
+ # Templates can access these value via the attr_reader-generated methods, but not the
62
+ # raw instance variable value.
63
+ # @author = options[:author]
64
+ end
65
+ end
@@ -0,0 +1,28 @@
1
+ # AMQP client configuration file
2
+
3
+ # These values will be used to configure the ampq gem, any values
4
+ # omitted will let the gem use it's own defaults.
5
+
6
+ # The configuration specifies the following keys:
7
+ # * user - Username for the broker
8
+ # * pass - Password for the broker
9
+ # * host - Hostname where the broker is running
10
+ # * vhost - Vhost to connect to
11
+ # * port - Port where the broker is running
12
+ # * ssl - Use ssl or not
13
+ # * timeout - Timeout
14
+
15
+ defaults: &defaults
16
+ user: guest
17
+ pass: guest
18
+ host: localhost
19
+ vhost: /
20
+
21
+ development:
22
+ <<: *defaults
23
+
24
+ test:
25
+ <<: *defaults
26
+
27
+ production:
28
+ <<: *defaults
@@ -0,0 +1,7 @@
1
+ begin
2
+ require 'amqp'
3
+ require 'mq'
4
+ rescue LoadError
5
+ $stderr.puts "Missing amqp gem. Please run 'gem install amqp'."
6
+ exit 1
7
+ end
@@ -0,0 +1,37 @@
1
+ # Generated amqp daemon
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
+ # IMPORTANT CONFIGURATION NOTE
15
+ #
16
+ # Please review and update 'config/amqp.yml' accordingly or this
17
+ # daemon won't work as advertised.
18
+
19
+ # Run an event-loop for processing
20
+ DaemonKit::AMQP.run do
21
+ # Inside this block we're running inside the reactor setup by the
22
+ # amqp gem. Any code in the examples (from the gem) would work just
23
+ # fine here.
24
+
25
+ # Uncomment this for connection keep-alive
26
+ # AMQP.conn.connection_status do |status|
27
+ # DaemonKit.logger.debug("AMQP connection status changed: #{status}")
28
+ # if status == :disconnected
29
+ # AMQP.conn.reconnect(true)
30
+ # end
31
+ # end
32
+
33
+ amq = ::MQ.new
34
+ amq.queue('test').subscribe do |msg|
35
+ DaemonKit.logger.debug "Received message: #{msg.inspect}"
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+