Class: Daemon::Command::StartCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Daemon::Command::StartCommand
- Defined in:
- lib/onapp/engine/command/start_command.rb
Overview
Used in interface project Starts MasterProcess
Instance Attribute Summary
Attributes inherited from BaseCommand
Attributes included from UserInterface
Instance Method Summary (collapse)
-
- (Object) execute
Entry point.
Methods inherited from BaseCommand
Methods included from UserInterface
Constructor Details
This class inherits a constructor from Daemon::Command::BaseCommand
Instance Method Details
- (Object) execute
Entry point
12 13 14 15 16 17 18 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 |
# File 'lib/onapp/engine/command/start_command.rb', line 12 def execute say 'Starting OnApp Engine...' if active >= allowed error "Already running #{active} workers. #{allowed} allowed." return false end pid = Daemon::MasterProcess.another_instance_pid if pid say "Found onapp engine #{pid}. Asking to spawn #{allowed - active} workers" Process.kill('USR1', pid) return true end if .forked say 'Spawning engine...' pid, err = Daemon::MasterProcess.new(forked: true).run if err || !pid error "Can't start engine!" error(err) if pid Process.kill(15, pid) rescue error("#{$!.class}: #{$!.}") end return false else say "Spawned #{pid}" return true end else say 'Running master process' Daemon::MasterProcess.new(forked: false).run return true end end |