Class: FireAndForget::Server
- Inherits:
-
Object
- Object
- FireAndForget::Server
- Defined in:
- lib/fire_and_forget/server.rb
Class Method Summary collapse
- .get_pid(task) ⇒ Object
- .kill(task_name, signal = "TERM") ⇒ Object
- .parse(command_string) ⇒ Object
- .pids ⇒ Object
- .run(cmd) ⇒ Object
- .set_pid(task_name, pid) ⇒ Object
- .status ⇒ Object
Class Method Details
.get_pid(task) ⇒ Object
30 31 32 |
# File 'lib/fire_and_forget/server.rb', line 30 def self.get_pid(task) pids[task.name] end |
.kill(task_name, signal = "TERM") ⇒ Object
17 18 19 20 |
# File 'lib/fire_and_forget/server.rb', line 17 def self.kill(task_name, signal="TERM") pid = pids[task_name] Process.kill(signal, pid) unless pid == 0 end |
.parse(command_string) ⇒ Object
4 5 6 7 |
# File 'lib/fire_and_forget/server.rb', line 4 def self.parse(command_string) command = Command.load(command_string) [command, run(command)] end |
.pids ⇒ Object
34 35 36 |
# File 'lib/fire_and_forget/server.rb', line 34 def self.pids @pids ||= {} end |
.run(cmd) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/fire_and_forget/server.rb', line 9 def self.run(cmd) if Command.allowed?(cmd) cmd.run else raise PermissionsError, "'#{cmd.class}' is not an approved command" end end |
.set_pid(task_name, pid) ⇒ Object
26 27 28 |
# File 'lib/fire_and_forget/server.rb', line 26 def self.set_pid(task_name, pid) pids[task_name] = pid.to_i end |
.status ⇒ Object
22 23 24 |
# File 'lib/fire_and_forget/server.rb', line 22 def self.status @status ||= {} end |