Class: Vedeu::Distributed::Subprocess Private
- Inherits:
-
Object
- Object
- Vedeu::Distributed::Subprocess
- Defined in:
- lib/vedeu/distributed/subprocess.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Creates a subprocess of the DRb server.
Instance Attribute Summary collapse
- #application ⇒ void readonly protected private
- #pid ⇒ Fixnum readonly protected private
Class Method Summary collapse
- .execute!(application) ⇒ Object private
Instance Method Summary collapse
- #command ⇒ String private private
-
#execute! ⇒ Array
private
:nocov:.
- #file_close ⇒ NilClass private private
- #file_name ⇒ String private private
- #file_open ⇒ File (also: #file) private private
-
#file_path ⇒ Object
private
private
return [String].
-
#file_unlink ⇒ Fixnum
private
private
The number of files removed; 1.
-
#file_write ⇒ Fixnum
private
private
The number of bytes written.
-
#initialize(application) ⇒ Vedeu::Distributed::Subprocess
constructor
private
Returns a new instance of Vedeu::Distributed::Subprocess.
-
#kill ⇒ void
private
Sends the KILL signal to the process.
-
#timestamp ⇒ Object
private
private
return [Fixnum].
Constructor Details
#initialize(application) ⇒ Vedeu::Distributed::Subprocess
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Distributed::Subprocess.
22 23 24 25 |
# File 'lib/vedeu/distributed/subprocess.rb', line 22 def initialize(application) @application = application @pid = nil end |
Instance Attribute Details
#application ⇒ void (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
53 54 55 |
# File 'lib/vedeu/distributed/subprocess.rb', line 53 def application @application end |
#pid ⇒ Fixnum (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/vedeu/distributed/subprocess.rb', line 57 def pid @pid end |
Class Method Details
.execute!(application) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/vedeu/distributed/subprocess.rb', line 14 def self.execute!(application) new(application).execute! end |
Instance Method Details
#command ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 |
# File 'lib/vedeu/distributed/subprocess.rb', line 62 def command "ruby #{file_path}" end |
#execute! ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
:nocov:
29 30 31 32 33 34 35 36 37 |
# File 'lib/vedeu/distributed/subprocess.rb', line 29 def execute! file_open && file_write && file_close @pid = fork { exec(file_path) } Process.detach(@pid) self end |
#file_close ⇒ NilClass (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 |
# File 'lib/vedeu/distributed/subprocess.rb', line 72 def file_close file.close end |
#file_name ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 |
# File 'lib/vedeu/distributed/subprocess.rb', line 93 def file_name Dir.tmpdir + "/foo_#{}" end |
#file_open ⇒ File (private) Also known as: file
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 |
# File 'lib/vedeu/distributed/subprocess.rb', line 87 def file_open @file ||= File.new(file_name, 'w', 0755) end |
#file_path ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
return [String]
82 83 84 |
# File 'lib/vedeu/distributed/subprocess.rb', line 82 def file_path file.path end |
#file_unlink ⇒ Fixnum (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The number of files removed; 1.
77 78 79 |
# File 'lib/vedeu/distributed/subprocess.rb', line 77 def file_unlink File.unlink(file_name) end |
#file_write ⇒ Fixnum (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The number of bytes written.
67 68 69 |
# File 'lib/vedeu/distributed/subprocess.rb', line 67 def file_write file.write(application) end |
#kill ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Sends the KILL signal to the process.
43 44 45 46 47 |
# File 'lib/vedeu/distributed/subprocess.rb', line 43 def kill Process.kill('KILL', pid) file_unlink end |
#timestamp ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
return [Fixnum]
98 99 100 |
# File 'lib/vedeu/distributed/subprocess.rb', line 98 def @timestamp ||= Time.now.to_i end |