Module: Epi
- Defined in:
- lib/epi.rb,
lib/epi/cli.rb,
lib/epi/job.rb,
lib/epi/data.rb,
lib/epi/jobs.rb,
lib/epi/daemon.rb,
lib/epi/launch.rb,
lib/epi/logging.rb,
lib/epi/trigger.rb,
lib/epi/version.rb,
lib/epi/connection.rb,
lib/epi/exceptions.rb,
lib/epi/cli/command.rb,
lib/epi/daemon/sender.rb,
lib/epi/process_status.rb,
lib/epi/triggers/touch.rb,
lib/epi/daemon/receiver.rb,
lib/epi/exceptions/base.rb,
lib/epi/job_description.rb,
lib/epi/running_process.rb,
lib/epi/triggers/memory.rb,
lib/epi/triggers/uptime.rb,
lib/epi/cli/commands/job.rb,
lib/epi/daemon/responder.rb,
lib/epi/exceptions/fatal.rb,
lib/epi/cli/commands/help.rb,
lib/epi/cli/commands/stop.rb,
lib/epi/cli/commands/start.rb,
lib/epi/configuration_file.rb,
lib/epi/cli/commands/config.rb,
lib/epi/cli/commands/daemon.rb,
lib/epi/cli/commands/status.rb,
lib/epi/exceptions/shutdown.rb,
lib/epi/cli/commands/restart.rb,
lib/epi/daemon/responders/job.rb,
lib/epi/daemon/responders/start.rb,
lib/epi/daemon/responders/config.rb,
lib/epi/daemon/responders/status.rb,
lib/epi/daemon/responders/shutdown.rb,
lib/epi/daemon/responders/stop_all.rb,
lib/epi/cli/commands/concerns/daemon.rb,
lib/epi/triggers/concerns/comparison.rb,
lib/epi/exceptions/invalid_configuration_file.rb
Defined Under Namespace
Modules: Cli, Daemon, Exceptions, Jobs, Triggers
Classes: ConfigurationFile, Connection, Data, Job, JobDescription, ProcessStatus, RunningProcess, Trigger
Constant Summary
collapse
- ROOT =
Pathname File.expand_path('../..', __FILE__)
- DEFAULT_LEVEL =
'info'
- VERSION =
'0.1.5'
Class Method Summary
collapse
Class Method Details
.launch(command, env: {}, user: nil, cwd: nil, stdout: true, stderr: true) ⇒ Fixnum
Run a system command in the background, and allow it to keep running
after Ruby has exited.
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/epi/launch.rb', line 19
def self.launch(command, env: {}, user: nil, cwd: nil, stdout: true, stderr: true)
cmd = 'nohup '
if String === command
cmd << command
else
command.each { |part| cmd << ' ' << escape(part) }
end
{:>> => stdout, :'2>>' => stderr}.each do |arrow, dest|
cmd << " #{arrow} #{dest || '/dev/null'}" unless TrueClass === dest
end
cmd << ' & echo $!'
cmd = "su #{user} -c #{escape cmd}" if user
cmd = "cd #{escape cwd} && (#{cmd})" if cwd
env = ENV.to_h.merge(env).map { |k, v| [k.to_s, v.to_s] }.to_h
logger.debug "Starting `#{cmd}`"
IO.popen(env, cmd) { |p| p.read }.to_i.tap do |pid|
logger.info "Process #{pid} started: #{`ps -p #{pid} -o command=`.chomp}"
end
end
|
.logger ⇒ Object
7
8
9
|
# File 'lib/epi/logging.rb', line 7
def logger
@logger ||= make_logger
end
|
.logger=(value) ⇒ Object
11
12
13
|
# File 'lib/epi/logging.rb', line 11
def logger=(value)
@logger = Logger === value ? value : make_logger(value)
end
|
.root? ⇒ Boolean
27
28
29
30
|
# File 'lib/epi.rb', line 27
def root?
@is_root = `whoami`.chomp == 'root' if @is_root.nil?
@is_root
end
|