euston-daemons 1.0.3-java → 1.0.4-java

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.4'
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 jvm_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.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: euston-daemons
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.3
5
+ version: 1.0.4
6
6
  platform: java
7
7
  authors:
8
8
  - Lee Henson
@@ -10,161 +10,161 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-20 00:00:00.000000000 +01:00
13
+ date: 2011-09-27 00:00:00.000000000 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activemodel
18
- version_requirements: &2158 !ruby/object:Gem::Requirement
18
+ version_requirements: &2334 !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.0.0
23
23
  none: false
24
- requirement: *2158
24
+ requirement: *2334
25
25
  prerelease: false
26
26
  type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
- version_requirements: &2176 !ruby/object:Gem::Requirement
29
+ version_requirements: &2352 !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.0.0
34
34
  none: false
35
- requirement: *2176
35
+ requirement: *2352
36
36
  prerelease: false
37
37
  type: :runtime
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: erb-yaml
40
- version_requirements: &2192 !ruby/object:Gem::Requirement
40
+ version_requirements: &2368 !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
44
  version: 1.0.0
45
45
  none: false
46
- requirement: *2192
46
+ requirement: *2368
47
47
  prerelease: false
48
48
  type: :runtime
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: hollywood
51
- version_requirements: &2208 !ruby/object:Gem::Requirement
51
+ version_requirements: &2384 !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: 1.0.0
56
56
  none: false
57
- requirement: *2208
57
+ requirement: *2384
58
58
  prerelease: false
59
59
  type: :runtime
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: i18n
62
- version_requirements: &2224 !ruby/object:Gem::Requirement
62
+ version_requirements: &2400 !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ~>
65
65
  - !ruby/object:Gem::Version
66
66
  version: 0.5.0
67
67
  none: false
68
- requirement: *2224
68
+ requirement: *2400
69
69
  prerelease: false
70
70
  type: :runtime
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: require_all
73
- version_requirements: &2240 !ruby/object:Gem::Requirement
73
+ version_requirements: &2416 !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 1.2.0
78
78
  none: false
79
- requirement: *2240
79
+ requirement: *2416
80
80
  prerelease: false
81
81
  type: :runtime
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: safely
84
- version_requirements: &2256 !ruby/object:Gem::Requirement
84
+ version_requirements: &2432 !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ~>
87
87
  - !ruby/object:Gem::Version
88
88
  version: 0.3.0
89
89
  none: false
90
- requirement: *2256
90
+ requirement: *2432
91
91
  prerelease: false
92
92
  type: :runtime
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: euston-rabbitmq
95
- version_requirements: &2272 !ruby/object:Gem::Requirement
95
+ version_requirements: &2448 !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - ~>
98
98
  - !ruby/object:Gem::Version
99
99
  version: 1.0.0
100
100
  none: false
101
- requirement: *2272
101
+ requirement: *2448
102
102
  prerelease: false
103
103
  type: :runtime
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: jessica
106
- version_requirements: &2288 !ruby/object:Gem::Requirement
106
+ version_requirements: &2464 !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.0.0
111
111
  none: false
112
- requirement: *2288
112
+ requirement: *2464
113
113
  prerelease: false
114
114
  type: :runtime
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: jmongo
117
- version_requirements: &2304 !ruby/object:Gem::Requirement
117
+ version_requirements: &2480 !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ~>
120
120
  - !ruby/object:Gem::Version
121
121
  version: 1.0.0
122
122
  none: false
123
- requirement: *2304
123
+ requirement: *2480
124
124
  prerelease: false
125
125
  type: :runtime
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: euston
128
- version_requirements: &2320 !ruby/object:Gem::Requirement
128
+ version_requirements: &2496 !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ~>
131
131
  - !ruby/object:Gem::Version
132
132
  version: 1.0.0
133
133
  none: false
134
- requirement: *2320
134
+ requirement: *2496
135
135
  prerelease: false
136
136
  type: :runtime
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: euston-eventstore
139
- version_requirements: &2336 !ruby/object:Gem::Requirement
139
+ version_requirements: &2512 !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - ~>
142
142
  - !ruby/object:Gem::Version
143
143
  version: 1.0.0
144
144
  none: false
145
- requirement: *2336
145
+ requirement: *2512
146
146
  prerelease: false
147
147
  type: :runtime
148
148
  - !ruby/object:Gem::Dependency
149
149
  name: mongoid-glue
150
- version_requirements: &2352 !ruby/object:Gem::Requirement
150
+ version_requirements: &2528 !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ~>
153
153
  - !ruby/object:Gem::Version
154
154
  version: 1.0.0
155
155
  none: false
156
- requirement: *2352
156
+ requirement: *2528
157
157
  prerelease: false
158
158
  type: :runtime
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: rspec
161
- version_requirements: &2368 !ruby/object:Gem::Requirement
161
+ version_requirements: &2544 !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - ~>
164
164
  - !ruby/object:Gem::Version
165
165
  version: 2.6.0
166
166
  none: false
167
- requirement: *2368
167
+ requirement: *2544
168
168
  prerelease: false
169
169
  type: :development
170
170
  description: ''