epi 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/epi/job.rb +1 -3
- data/lib/epi/launch.rb +11 -5
- data/lib/epi/process_status.rb +1 -1
- data/lib/epi/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5e7e4338b1beae6f3f58eb12974ea98b1093d0a
|
4
|
+
data.tar.gz: 1b9090a1e6de1c5f6ae089afb5c716d524afa5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3da43bc5ee0f6f19b9d39cda86029b0c076a16bad0d5e6fa4d40aebac2c0c9555643cfae13c436a5afd60635034b5c1893a774e9cf5c7d6d5289d24d26987d4
|
7
|
+
data.tar.gz: f2efd89e32244861ce7532f02cf7d4dd22447f1a2ada753a951e3da7006802625bb8b872b8dbf4afb1254859de11c4bf00a564fe31b7057eae9ace4209a4e79b
|
data/lib/epi/job.rb
CHANGED
@@ -112,9 +112,7 @@ module Epi
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def running_processes
|
115
|
-
pids.map
|
116
|
-
[proc_id, ProcessStatus[pid] || RunningProcess.new(pid)]
|
117
|
-
end.to_h
|
115
|
+
pids.map { |proc_id, pid| [proc_id, ProcessStatus[pid] || RunningProcess.new(pid)] }.select { |_, v| v.was_alive? }.to_h
|
118
116
|
end
|
119
117
|
|
120
118
|
def running_count
|
data/lib/epi/launch.rb
CHANGED
@@ -29,12 +29,9 @@ module Epi
|
|
29
29
|
else
|
30
30
|
|
31
31
|
# Command and arguments that need to be escaped
|
32
|
-
command.each { |part| cmd << ' ' <<
|
32
|
+
command.each { |part| cmd << ' ' << escape(part) }
|
33
33
|
end
|
34
34
|
|
35
|
-
# Include `su` command if a user is given
|
36
|
-
cmd = "su #{user} -c #{cmd}" if user
|
37
|
-
|
38
35
|
# STDOUT and STDERR redirection
|
39
36
|
{:>> => stdout, :'2>>' => stderr}.each do |arrow, dest|
|
40
37
|
cmd << " #{arrow} #{dest || '/dev/null'}" unless TrueClass === dest
|
@@ -43,8 +40,11 @@ module Epi
|
|
43
40
|
# Run in background, and return PID of backgrounded process
|
44
41
|
cmd << ' & echo $!'
|
45
42
|
|
43
|
+
# Include `su` command if a user is given
|
44
|
+
cmd = "su #{user} -c #{escape cmd}" if user
|
45
|
+
|
46
46
|
# Include the working directory
|
47
|
-
cmd = "cd #{
|
47
|
+
cmd = "cd #{escape cwd} && (#{cmd})" if cwd
|
48
48
|
|
49
49
|
# Convert environment variables to strings, and merge them with the current environment
|
50
50
|
env = ENV.to_h.merge(env).map { |k, v| [k.to_s, v.to_s] }.to_h
|
@@ -56,4 +56,10 @@ module Epi
|
|
56
56
|
logger.info "Process #{pid} started: #{`ps -p #{pid} -o command=`.chomp}"
|
57
57
|
end
|
58
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def self.escape(*args)
|
63
|
+
Shellwords.escape *args
|
64
|
+
end
|
59
65
|
end
|
data/lib/epi/process_status.rb
CHANGED
@@ -54,7 +54,7 @@ module Epi
|
|
54
54
|
@running_processes = {}
|
55
55
|
|
56
56
|
# Run `ps`
|
57
|
-
result = %x(ps
|
57
|
+
result = %x(ps ax -o #{RunningProcess::PS_FORMAT})
|
58
58
|
|
59
59
|
# Split into lines, and get rid of the first (heading) line
|
60
60
|
@lines = result.lines[1..-1].map { |line| [line.lstrip.split(/\s/, 2).first.to_i, line] }.to_h
|
data/lib/epi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil E. Pearson
|
@@ -106,3 +106,4 @@ signing_key:
|
|
106
106
|
specification_version: 4
|
107
107
|
summary: Epinephrine
|
108
108
|
test_files: []
|
109
|
+
has_rdoc:
|