serfx 0.0.7 → 0.0.8
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.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/lib/serfx.rb +5 -5
- data/lib/serfx/utils/async_job.rb +14 -2
- data/lib/serfx/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93d9b356f7f57d5d478e7029cfd102ba0f4df9c9
|
4
|
+
data.tar.gz: 56328c5f96c7b274a1b1e9cafd3e6d34cf0ee989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d00717242ab33e17855a25952e4d75c820e9cfc4b13aa6a3cabde733701bb6736abf00dcf0d15964398c3eba954fdf14135279e4c1196d023e5a12a22d0c63e6
|
7
|
+
data.tar.gz: b2244787a7fa11cd352b44d74f4ee44dc6b75e47f285fcee053ff1c9e12c448f78d8e1866f3fb63008605a32897fb3b6039e5fa6cdffcca1e0c9327c4884942b
|
data/.travis.yml
CHANGED
data/lib/serfx.rb
CHANGED
@@ -7,16 +7,16 @@ require 'serfx/connection'
|
|
7
7
|
# Serfx is a minimal ruby client for serf.
|
8
8
|
module Serfx
|
9
9
|
# Creates a serf rpc connection, performs handshake and auth
|
10
|
-
# (if authkey is supplied),
|
11
|
-
#
|
12
|
-
# execution
|
10
|
+
# (if authkey is supplied). If a block is provided, the connection
|
11
|
+
# object will be yield-ed and the connection will be closed after
|
12
|
+
# the block's execution, otherwise the connection will be returned
|
13
13
|
# Params:
|
14
14
|
# +opts+:: An optional hash which can have following keys:
|
15
15
|
# * host => Serf host's rpc bind address (127.0.0.1 by default)
|
16
16
|
# * port => Serf host's rpc port (7373 by default)
|
17
17
|
# * authkey => Encryption key for RPC communiction
|
18
18
|
#
|
19
|
-
# @return value of the block evaluation
|
19
|
+
# @return value of the block evaluation or the connection object
|
20
20
|
def self.connect(opts = {})
|
21
21
|
conn = Serfx::Connection.new(opts)
|
22
22
|
conn.handshake
|
@@ -25,9 +25,9 @@ module Serfx
|
|
25
25
|
if block_given?
|
26
26
|
res = yield conn
|
27
27
|
conn.close unless conn.closed?
|
28
|
+
res
|
28
29
|
else
|
29
30
|
conn
|
30
31
|
end
|
31
|
-
res
|
32
32
|
end
|
33
33
|
end
|
@@ -68,7 +68,13 @@ module Serfx
|
|
68
68
|
# serf query bash_test reap # delete a finished job's state file
|
69
69
|
# serf query bash_test kill
|
70
70
|
class AsyncJob
|
71
|
-
|
71
|
+
|
72
|
+
attr_reader :command
|
73
|
+
attr_reader :state_file
|
74
|
+
attr_reader :stdout_file
|
75
|
+
attr_reader :stderr_file
|
76
|
+
attr_reader :environment
|
77
|
+
attr_reader :cwd
|
72
78
|
|
73
79
|
# @param opts [Hash] specify the job details
|
74
80
|
# @option opts [Symbol] :state file path which will be used to store
|
@@ -77,11 +83,15 @@ module Serfx
|
|
77
83
|
# in the background
|
78
84
|
# @option opts [Symbol] :stdout standard output file for the task
|
79
85
|
# @option opts [Symbol] :stderr standard error file for the task
|
86
|
+
# @option opts [Symbol] :environment a hash containing environment variables
|
87
|
+
# @option opts [Symbol] :cwd a string (directory path) containing current directory of the command
|
80
88
|
def initialize(opts = {})
|
81
89
|
@state_file = opts[:state] || fail(ArgumentError, 'Specify state file')
|
82
90
|
@command = opts[:command]
|
83
91
|
@stdout_file = opts[:stdout] || File::NULL
|
84
92
|
@stderr_file = opts[:stderr] || File::NULL
|
93
|
+
@environment = opts[:environment] || {}
|
94
|
+
@cwd = opts[:cwd] || Dir.pwd
|
85
95
|
end
|
86
96
|
|
87
97
|
# kill an already running task
|
@@ -153,9 +163,11 @@ module Serfx
|
|
153
163
|
write_state(state)
|
154
164
|
begin
|
155
165
|
child_pid = Process.spawn(
|
166
|
+
environment,
|
156
167
|
command,
|
157
168
|
out: stdout_file,
|
158
|
-
err: stderr_file
|
169
|
+
err: stderr_file,
|
170
|
+
chdir: cwd
|
159
171
|
)
|
160
172
|
state[:pid] = child_pid
|
161
173
|
state[:status] = 'running'
|
data/lib/serfx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serfx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rnjib Dey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|