symphony 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edb7810dc562110768235353536ec4a000b02828
4
- data.tar.gz: c0a047b0115a9a865ce90606478091e814ab23f5
3
+ metadata.gz: 27cfb2845ca71c3af5596979ce84fb19c9a3ba6e
4
+ data.tar.gz: f475feb878e9abf0be8f4fc16fd90f86d7d04193
5
5
  SHA512:
6
- metadata.gz: 26eeea9cdd2546eeb51cf3f6f936e59a69886c0f83d431e8c770ce758564df01153cb710ff73abbb36fd9525f1234f3912f0fc74cb6bc0c01e14df1af437a854
7
- data.tar.gz: ab8aa95349260ee6782133c5d151ad4e749cd77d906616c48c06cd7b7bdb84b4c94b89126c67032fe469e56ec342d5e0eecac82cf3b82da6330200d1f329d771
6
+ metadata.gz: 75fcf22eea9e1f738eeb502fe7bd31f5ae0c8b845857cd5610404f9943f89303fa2d84713174bda7c753f82e893604325de89fa9594292630d0e70180d781d43
7
+ data.tar.gz: 550773eda18d10aa46e7bdc1f9a3a14b1e483a9aec9268e65b0c530ae1d19f02972facb0252cb7316f2bb689cca7d21fbbf68809909a152bd5e4c9ace43171d1
Binary file
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,9 +1,41 @@
1
+ 2014-04-14 Mahlon E. Smith <mahlon@laika.com>
2
+
3
+ * Rakefile:
4
+ Add configurability to the dependencies list.
5
+ [f73d3ee81d17] [tip]
6
+
7
+ 2014-04-14 Michael Granger <ged@FaerieMUD.org>
8
+
9
+ * .hgtags:
10
+ Added tag v0.6.0 for changeset a088731f43ff
11
+ [718f55893ad5]
12
+
13
+ * .hgsigs:
14
+ Added signature for changeset fa6a367872f4
15
+ [a088731f43ff] [v0.6.0]
16
+
17
+ * History.rdoc, lib/symphony.rb:
18
+ Bump the minor version, update history
19
+ [fa6a367872f4] [github/master]
20
+
21
+ * TODO.md, lib/symphony/queue.rb, spec/symphony/queue_spec.rb:
22
+ Update the TO-DO list
23
+ [b30f07c96e7e]
24
+
25
+ * lib/symphony/queue.rb:
26
+ Set cancel-on-failover flag to the queue consumer
27
+ [7c4d92ddbc79]
28
+
29
+ * Rakefile:
30
+ Remove the ssh-related dev deps
31
+ [ccfe90203de7]
32
+
1
33
  2014-04-14 Mahlon E. Smith <mahlon@laika.com>
2
34
 
3
35
  * Manifest.txt, Rakefile, lib/symphony/tasks/ssh.rb,
4
36
  lib/symphony/tasks/sshscript.rb:
5
37
  Branch merge from 221b25852ba6.
6
- [3673b0e7202d] [tip]
38
+ [3673b0e7202d]
7
39
 
8
40
  * .hoerc, Manifest.txt, spec/symphony/mixins_spec.rb:
9
41
  Complete the intervalexpression backout.
@@ -41,7 +73,7 @@
41
73
 
42
74
  * .hgtags:
43
75
  Added tag v0.5.0 for changeset f8e6883990fc
44
- [41fc4926342b] [github/master]
76
+ [41fc4926342b]
45
77
 
46
78
  * .hgsigs:
47
79
  Added signature for changeset 369353a62297
@@ -1,3 +1,13 @@
1
+ == v0.7.0 [2014-05-05] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Add a 'before_fork' hook to Symphony::Task.
4
+
5
+
6
+ == v0.6.1 [2014-04-23] Michael Granger <ged@FaerieMUD.org>
7
+
8
+ Handle SIGQUIT the same as SIGINT and SIGTERM in the daemon.
9
+
10
+
1
11
  == v0.6.0 [2014-04-14] Michael Granger <ged@FaerieMUD.org>
2
12
 
3
13
  - Set cancel-on-failover flag in the queue consumer
data/Rakefile CHANGED
@@ -27,6 +27,7 @@ hoespec = Hoe.spec 'symphony' do |spec|
27
27
  spec.developer 'Michael Granger', 'ged@FaerieMUD.org'
28
28
  spec.developer 'Mahlon E. Smith', 'mahlon@martini.nu'
29
29
 
30
+ spec.dependency 'configurability', '~> 2.1'
30
31
  spec.dependency 'loggability', '~> 0.10'
31
32
  spec.dependency 'pluggability', '~> 0.4'
32
33
  spec.dependency 'bunny', '~> 1.1'
@@ -12,10 +12,10 @@ module Symphony
12
12
  Configurability
13
13
 
14
14
  # Library version constant
15
- VERSION = '0.6.0'
15
+ VERSION = '0.7.0'
16
16
 
17
17
  # Version-control revision constant
18
- REVISION = %q$Revision: fa6a367872f4 $
18
+ REVISION = %q$Revision: 52300e72d138 $
19
19
 
20
20
 
21
21
  # The name of the environment variable to check for config file overrides
@@ -113,9 +113,6 @@ class Symphony::Daemon
113
113
 
114
114
  ### Create a new Daemon instance.
115
115
  def initialize
116
- # Process control
117
- @tasks = self.class.tasks
118
-
119
116
  @running_tasks = {}
120
117
  @running = false
121
118
  @shutting_down = false
@@ -143,6 +140,10 @@ class Symphony::Daemon
143
140
  attr_reader :config
144
141
 
145
142
 
143
+ # Make a delegator for the class's task list
144
+ define_method( :tasks, &self.method(:tasks) )
145
+
146
+
146
147
  ### Returns +true+ if the daemon is still running.
147
148
  def running?
148
149
  return @running
@@ -236,7 +237,7 @@ class Symphony::Daemon
236
237
  def handle_signal( sig )
237
238
  self.log.debug "Handling signal %s in PID %d" % [ sig, Process.pid ]
238
239
  case sig
239
- when :INT, :TERM
240
+ when :INT, :TERM, :QUIT
240
241
  if @running
241
242
  self.log.warn "%s signal: graceful shutdown" % [ sig ]
242
243
  @running = false
@@ -338,6 +339,7 @@ class Symphony::Daemon
338
339
  return if self.shutting_down?
339
340
 
340
341
  self.log.debug "Starting a %p." % [ task_class ]
342
+ task_class.before_fork
341
343
  pid = Process.fork do
342
344
  task_class.after_fork
343
345
  task_class.run
@@ -108,5 +108,12 @@ module Symphony::SignalHandling
108
108
  end
109
109
 
110
110
 
111
+ ### Simulate the receipt of the specified +signal+ (probably only useful
112
+ ### in testing).
113
+ def simulate_signal( signal )
114
+ Thread.main[:signal_queue] << signal.to_sym
115
+ self.wake_up
116
+ end
117
+
111
118
  end # module Symphony::SignalHandling
112
119
 
@@ -51,6 +51,13 @@ class Symphony::Task
51
51
  end
52
52
 
53
53
 
54
+ ### Prepare the process to be forked.
55
+ def self::before_fork
56
+ self.log.debug "Before fork [%d]: Threads: %p" % [ Process.pid, ThreadGroup::Default.list ]
57
+ # No-op
58
+ end
59
+
60
+
54
61
  ### Prepare the process after being forked from the Daemon.
55
62
  def self::after_fork
56
63
  self.log.debug "After fork [%d]: Threads: %p" % [ Process.pid, ThreadGroup::Default.list ]
@@ -5,9 +5,80 @@ require_relative '../helpers'
5
5
 
6
6
  require 'symphony/daemon'
7
7
 
8
+ class TestTask < Symphony::Task
9
+
10
+ # Don't ever really try to handle messages.
11
+ def start_handling_messages
12
+ end
13
+
14
+ end
15
+
16
+
8
17
  describe Symphony::Daemon do
9
18
 
19
+ before( :each ) do
20
+ allow( Process ).to receive( :fork ).and_yield
21
+ allow( Process ).to receive( :setpgid )
22
+ Symphony::Daemon.configure( tasks: ['test', 'test'] )
23
+ end
24
+
25
+
26
+ let( :daemon ) { described_class.new }
27
+
28
+
29
+ it "can report what version it is" do
30
+ expect(
31
+ described_class.version_string
32
+ ).to match( /#{described_class} #{Symphony::VERSION}/i )
33
+ end
34
+
35
+ it "can include its build number in its version string" do
36
+ expect(
37
+ described_class.version_string( true )
38
+ ).to match( /\(build \p{Xdigit}+\)/i )
39
+ end
40
+
41
+ it "loads a task class for each configured task" do
42
+ expect( daemon.tasks.size ).to eq( 2 )
43
+ expect( daemon.tasks ).to include( TestTask )
44
+ end
45
+
46
+ it "forks a child for each task" do
47
+ expect( Process ).to receive( :fork ).twice.and_yield
48
+ expect( TestTask ).to receive( :after_fork ).twice
49
+ expect( TestTask ).to receive( :run ).and_return( 118, 119 ) # pids
50
+
51
+ daemon.simulate_signal( :TERM )
52
+
53
+ status = double( Process::Status, :success? => true )
54
+ expect( Process ).to receive( :waitpid2 ).
55
+ with( -1, Process::WNOHANG|Process::WUNTRACED ).
56
+ and_return( [118, status], [119, status], nil )
57
+
58
+ daemon.run_tasks
59
+ end
60
+
61
+ it "exits gracefully on one SIGINT" do
62
+ daemon.tasks.clear
63
+ thr = Thread.new { daemon.run_tasks }
64
+ sleep 0.1 until daemon.running? || !thr.alive?
65
+
66
+ expect {
67
+ daemon.simulate_signal( :INT )
68
+ thr.join( 2 )
69
+ }.to change { daemon.running? }.from( true ).to( false )
70
+ end
71
+
72
+ it "exits gracefully on one SIGQUIT" do
73
+ daemon.tasks.clear
74
+ thr = Thread.new { daemon.run_tasks }
75
+ sleep 0.1 until daemon.running? || !thr.alive?
10
76
 
77
+ expect {
78
+ daemon.simulate_signal( :QUIT )
79
+ thr.join( 2 )
80
+ }.to change { daemon.running? }.from( true ).to( false )
81
+ end
11
82
 
12
83
  end
13
84
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symphony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -31,8 +31,22 @@ cert_chain:
31
31
  c7ZKPJcWBv0sm81+FCZXNACn2f9jfF8OQinxVs0O052KbGuEQaaiGIYeuuwQE2q6
32
32
  ggcrPfcYeTwWlfZPu2LrBg==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-04-14 00:00:00.000000000 Z
34
+ date: 2014-05-05 00:00:00.000000000 Z
35
35
  dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: configurability
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: '2.1'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: '2.1'
36
50
  - !ruby/object:Gem::Dependency
37
51
  name: loggability
38
52
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- ���rÛ��G��\�w!C���4��vo<�*�a˚�����9:�hT5WEv�Y�suQoMvDRW;��%c��o�| ���OW\5�h~��\��͠-n@߹+���!HZ
1
+ =`ܢ���:b�a-q6P0rج@��D��&���f{���ȅ )����qN�^�ˠ�������X�&�k�FK��?kI^ܐS���f �?�������o)��ǒ ��f��Y�3n����� Q�ǘ�����og��� /�Z�.�D1qA��y����Џ���*��X��� ���k}��d.� ���\�L�.Y����ԙˑ�J��2T�´\p��/rn��:���v�&h ��lM���L��/Q