Class: ProcessBot::Process::Handlers::Custom
- Inherits:
-
Object
- Object
- ProcessBot::Process::Handlers::Custom
- Defined in:
- lib/process_bot/process/handlers/custom.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
Instance Method Summary collapse
- #current_pid ⇒ Object
- #daemonize ⇒ Object
- #false_value?(value) ⇒ Boolean
- #fetch(*args, **opts) ⇒ Object
-
#initialize(process) ⇒ Custom
constructor
A new instance of Custom.
- #logger ⇒ Object
- #set(*args, **opts) ⇒ Object
- #set_option(key, value) ⇒ Object
- #start_command ⇒ Object
- #stop(**_args) ⇒ Object
Constructor Details
#initialize(process) ⇒ Custom
Returns a new instance of Custom.
4 5 6 7 |
# File 'lib/process_bot/process/handlers/custom.rb', line 4 def initialize(process) @process = process @options = process. end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/process_bot/process/handlers/custom.rb', line 2 def @options end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
2 3 4 |
# File 'lib/process_bot/process/handlers/custom.rb', line 2 def process @process end |
Instance Method Details
#current_pid ⇒ Object
9 10 11 |
# File 'lib/process_bot/process/handlers/custom.rb', line 9 def current_pid process.current_pid end |
#daemonize ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/process_bot/process/handlers/custom.rb', line 13 def daemonize logger.logs "Daemonize!" pid = Process.fork do Process.daemon yield end Process.detach(pid) if pid end |
#false_value?(value) ⇒ Boolean
24 25 26 |
# File 'lib/process_bot/process/handlers/custom.rb', line 24 def false_value?(value) !value || value == "false" end |
#fetch(*args, **opts) ⇒ Object
28 29 30 |
# File 'lib/process_bot/process/handlers/custom.rb', line 28 def fetch(*args, **opts) .fetch(*args, **opts) end |
#logger ⇒ Object
32 33 34 |
# File 'lib/process_bot/process/handlers/custom.rb', line 32 def logger @logger ||= ProcessBot::Logger.new(options: ) end |
#set(*args, **opts) ⇒ Object
42 43 44 |
# File 'lib/process_bot/process/handlers/custom.rb', line 42 def set(*args, **opts) .set(*args, **opts) end |
#set_option(key, value) ⇒ Object
36 37 38 39 40 |
# File 'lib/process_bot/process/handlers/custom.rb', line 36 def set_option(key, value) raise "Unknown option for Sidekiq handler: #{key}" unless .key?(key) set(key, value) end |
#start_command ⇒ Object
46 47 48 |
# File 'lib/process_bot/process/handlers/custom.rb', line 46 def start_command "bash -c 'cd #{.fetch(:release_path)} && #{..fetch(:custom_command)}'" end |
#stop(**_args) ⇒ Object
50 51 52 53 |
# File 'lib/process_bot/process/handlers/custom.rb', line 50 def stop(**_args) puts "Stop related processes" process.runner. end |