euston-daemons 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'euston-daemons'
3
- s.version = '1.0.3'
3
+ s.version = '1.0.5'
4
4
  s.platform = RUBY_PLATFORM.to_s == 'java' ? 'java' : Gem::Platform::RUBY
5
5
  s.authors = ['Lee Henson', 'Guy Boertje']
6
6
  s.email = ['lee.m.henson@gmail.com', 'guyboertje@gmail.com']
@@ -29,12 +29,14 @@ module Euston
29
29
  attr_accessor :verbose
30
30
 
31
31
  def initialize(*args)
32
- @name = args.shift || :daemon
32
+ @name = args.shift || :eustondaemon
33
33
  @log_path = '/var/log/euston.log'
34
34
  @verbose = true
35
35
 
36
36
  Object.const_set :EUSTON_ENV, get_environment unless Object.const_defined? :EUSTON_ENV
37
37
 
38
+ @pid_path = pid_path_for_env + "#{@name}.pid"
39
+
38
40
  yield self if block_given?
39
41
  send :before_creating_task if respond_to? :before_creating_task
40
42
 
@@ -62,6 +64,15 @@ module Euston
62
64
  environment
63
65
  end
64
66
 
67
+ def pid_path_for_env
68
+ case get_environment
69
+ when :development, :test
70
+ '~/var/run/euston/'
71
+ else
72
+ '/var/run/euston/'
73
+ end
74
+ end
75
+
65
76
  def initialize_logger
66
77
  Object.const_set :EUSTON_LOG, Logger.new(@log_path.gsub(/\.log$/, ".#{EUSTON_ENV}.log"))
67
78
  end
@@ -70,6 +81,14 @@ module Euston
70
81
  # virtual
71
82
  end
72
83
 
84
+ def rake_pid
85
+ if defined? Java
86
+ Java::JavaIo::File.new("/proc/self").canonical_file.name
87
+ else
88
+ File.readlink("/proc/self")
89
+ end
90
+ end
91
+
73
92
  def launch_and_wait_for_exit
74
93
  ns = Object
75
94
 
@@ -79,8 +98,10 @@ module Euston
79
98
  end
80
99
 
81
100
  daemon = ns.new
101
+ create_pid_file
82
102
  trap_exit_signals daemon
83
103
  daemon.run
104
+ remove_pid_file
84
105
  end
85
106
 
86
107
  def load_framework
@@ -88,6 +109,16 @@ module Euston
88
109
  require_rel 'framework'
89
110
  end
90
111
 
112
+ def create_pid_file
113
+ File.open( @pid_path, 'w' ) { |f|
114
+ f.puts rake_pid
115
+ }
116
+ end
117
+
118
+ def remove_pid_file
119
+ File.delete( @pid_path ) rescue Errno::ENOENT
120
+ end
121
+
91
122
  def log_shutdown
92
123
  print_log_banner "Daemon shut down: #{@daemon_class}"
93
124
  end
@@ -1,5 +1,5 @@
1
1
  module Euston
2
2
  module Daemons
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: euston-daemons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-20 00:00:00.000000000 Z
13
+ date: 2011-09-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
17
- requirement: &81760130 !ruby/object:Gem::Requirement
17
+ requirement: &21218820 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *81760130
25
+ version_requirements: *21218820
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activesupport
28
- requirement: &81759760 !ruby/object:Gem::Requirement
28
+ requirement: &21217900 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 3.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *81759760
36
+ version_requirements: *21217900
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: erb-yaml
39
- requirement: &81759360 !ruby/object:Gem::Requirement
39
+ requirement: &21217040 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.0.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *81759360
47
+ version_requirements: *21217040
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: hollywood
50
- requirement: &81759040 !ruby/object:Gem::Requirement
50
+ requirement: &21216500 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *81759040
58
+ version_requirements: *21216500
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: i18n
61
- requirement: &81758510 !ruby/object:Gem::Requirement
61
+ requirement: &21215860 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.5.0
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *81758510
69
+ version_requirements: *21215860
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: require_all
72
- requirement: &81758000 !ruby/object:Gem::Requirement
72
+ requirement: &21215080 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 1.2.0
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *81758000
80
+ version_requirements: *21215080
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: safely
83
- requirement: &81757700 !ruby/object:Gem::Requirement
83
+ requirement: &21214260 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 0.3.0
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *81757700
91
+ version_requirements: *21214260
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: euston
94
- requirement: &81757290 !ruby/object:Gem::Requirement
94
+ requirement: &21213320 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ~>
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 1.0.0
100
100
  type: :runtime
101
101
  prerelease: false
102
- version_requirements: *81757290
102
+ version_requirements: *21213320
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: euston-eventstore
105
- requirement: &81756890 !ruby/object:Gem::Requirement
105
+ requirement: &21212740 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ~>
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: 1.0.0
111
111
  type: :runtime
112
112
  prerelease: false
113
- version_requirements: *81756890
113
+ version_requirements: *21212740
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: mongoid-glue
116
- requirement: &81756440 !ruby/object:Gem::Requirement
116
+ requirement: &21211960 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ~>
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: 1.0.0
122
122
  type: :runtime
123
123
  prerelease: false
124
- version_requirements: *81756440
124
+ version_requirements: *21211960
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
- requirement: &81756000 !ruby/object:Gem::Requirement
127
+ requirement: &21211260 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ~>
@@ -132,7 +132,7 @@ dependencies:
132
132
  version: 2.6.0
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *81756000
135
+ version_requirements: *21211260
136
136
  description: ''
137
137
  email:
138
138
  - lee.m.henson@gmail.com
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project:
198
- rubygems_version: 1.8.10
198
+ rubygems_version: 1.8.6
199
199
  signing_key:
200
200
  specification_version: 3
201
201
  summary: Message buffer, command processor and event processor daemons for Euston-RabbitMq