zeusd 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -3
- data/lib/zeusd/daemon.rb +16 -14
- data/lib/zeusd/version.rb +1 -1
- data/zeusd.gemspec +4 -4
- metadata +20 -20
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# Zeusd [![Gem Version](https://badge.fury.io/rb/zeusd.png)](http://badge.fury.io/rb/zeusd) [![Build Status](https://travis-ci.org/veloper/zeusd.png?branch=master)](https://travis-ci.org/veloper/zeusd) [![Code Climate](https://codeclimate.com/github/veloper/zeusd.png)](https://codeclimate.com/github/veloper/zeusd)
|
2
2
|
|
3
|
-
|
3
|
+
Zeusd aims to provide greater control and easier scripting of the [Zeus Gem](https://github.com/burke/zeus) via daemonization.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Feautres
|
6
6
|
|
7
|
-
|
7
|
+
* Run the [Zeus Gem](https://github.com/burke/zeus) as a daemon.
|
8
|
+
* Optionally block execution until Zeus has finished loaded using the `--block` flag.
|
9
|
+
* Manage multiple zeusd daemons using the `--cwd` flag.
|
10
|
+
|
11
|
+
## Usage
|
8
12
|
|
9
13
|
### Primary Commands
|
10
14
|
|
data/lib/zeusd/daemon.rb
CHANGED
@@ -7,18 +7,18 @@ module Zeusd
|
|
7
7
|
class DaemonException < StandardError; end
|
8
8
|
|
9
9
|
class Daemon
|
10
|
+
attr_reader :cwd, :verbose, :log_file, :log_queue, :interpreter, :child_process
|
11
|
+
|
12
|
+
|
10
13
|
include Hooks
|
11
|
-
define_hooks :
|
14
|
+
define_hooks :after_start!, :after_stop!, :after_output
|
12
15
|
|
13
16
|
after_start! { log(:start) }
|
14
17
|
after_stop! { log(:stop) }
|
15
18
|
after_output {|x| log(x, :zeus) }
|
16
19
|
|
17
|
-
after_start_process! :ensure_log_worker
|
18
|
-
|
19
20
|
after_stop! do
|
20
21
|
(socket_file.delete rescue nil) if socket_file.exist?
|
21
|
-
@process = nil
|
22
22
|
end
|
23
23
|
|
24
24
|
after_output do |output|
|
@@ -26,8 +26,6 @@ module Zeusd
|
|
26
26
|
puts(output) if verbose?
|
27
27
|
end
|
28
28
|
|
29
|
-
attr_reader :cwd, :verbose, :log_file, :log_queue, :interpreter, :child_process
|
30
|
-
|
31
29
|
def initialize(options = {})
|
32
30
|
@cwd = Pathname.new(options[:cwd] || Dir.pwd).realpath
|
33
31
|
@verbose = !!options[:verbose]
|
@@ -35,7 +33,9 @@ module Zeusd
|
|
35
33
|
end
|
36
34
|
|
37
35
|
def start!(options = {})
|
38
|
-
|
36
|
+
start_child_process!
|
37
|
+
|
38
|
+
@process = Zeusd::Process.find(child_process.pid)
|
39
39
|
|
40
40
|
if options.fetch(:block, false)
|
41
41
|
sleep(0.1) until loaded?
|
@@ -53,7 +53,7 @@ module Zeusd
|
|
53
53
|
def stop!
|
54
54
|
return self unless process
|
55
55
|
|
56
|
-
# Kill
|
56
|
+
# Kill process tree and wait for exits
|
57
57
|
process.kill!(:recursive => true, :wait => true)
|
58
58
|
|
59
59
|
# Check for remaining processes
|
@@ -61,6 +61,8 @@ module Zeusd
|
|
61
61
|
raise DaemonException, "Unable to KILL processes: " + alive_processes.join(', ')
|
62
62
|
end
|
63
63
|
|
64
|
+
@process = nil
|
65
|
+
|
64
66
|
self
|
65
67
|
ensure
|
66
68
|
run_hook :after_stop!
|
@@ -74,7 +76,6 @@ module Zeusd
|
|
74
76
|
interpreter.complete?
|
75
77
|
end
|
76
78
|
|
77
|
-
|
78
79
|
def log_file
|
79
80
|
cwd.join('log/zeusd.log')
|
80
81
|
end
|
@@ -105,17 +106,18 @@ module Zeusd
|
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
108
|
-
def
|
109
|
+
def start_child_process!
|
109
110
|
@reader, @writer = IO.pipe
|
110
|
-
@child_process
|
111
|
+
@child_process = ChildProcess.build("zeus", "start")
|
111
112
|
@child_process.environment["BUNDLE_GEMFILE"] = cwd.join("Gemfile").to_path
|
112
113
|
@child_process.io.stdout = @child_process.io.stderr = @writer
|
113
|
-
@child_process.cwd
|
114
|
-
@child_process.detach
|
114
|
+
@child_process.cwd = cwd.to_path
|
115
|
+
@child_process.detach = true
|
115
116
|
@child_process.start
|
117
|
+
|
116
118
|
@writer.close
|
117
119
|
|
118
|
-
|
120
|
+
ensure_log_worker
|
119
121
|
|
120
122
|
Thread.new do
|
121
123
|
while (buffer = (@reader.readpartial(10000) rescue nil)) do
|
data/lib/zeusd/version.rb
CHANGED
data/zeusd.gemspec
CHANGED
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "thor"
|
22
|
-
spec.add_runtime_dependency "childprocess"
|
23
|
-
spec.add_runtime_dependency "hooks"
|
24
|
-
spec.add_runtime_dependency "zeus"
|
21
|
+
spec.add_runtime_dependency "thor" , "~> 0.18.1"
|
22
|
+
spec.add_runtime_dependency "childprocess" , "~> 0.4.0"
|
23
|
+
spec.add_runtime_dependency "hooks" , "~> 0.3.3"
|
24
|
+
spec.add_runtime_dependency "zeus" , "~> 0.13.3"
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
27
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zeusd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,72 +9,72 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.18.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 0.18.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: childprocess
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 0.4.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 0.4.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: hooks
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 0.3.3
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.3.3
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: zeus
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 0.13.3
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 0.13.3
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: bundler
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -215,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
215
|
version: '0'
|
216
216
|
segments:
|
217
217
|
- 0
|
218
|
-
hash:
|
218
|
+
hash: 3492660387363496392
|
219
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
220
|
none: false
|
221
221
|
requirements:
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
segments:
|
226
226
|
- 0
|
227
|
-
hash:
|
227
|
+
hash: 3492660387363496392
|
228
228
|
requirements: []
|
229
229
|
rubyforge_project:
|
230
230
|
rubygems_version: 1.8.25
|