Class: Exekutor::Internal::CLI::Manager
- Inherits:
-
Object
- Object
- Exekutor::Internal::CLI::Manager
- Includes:
- ApplicationLoader
- Defined in:
- lib/exekutor/internal/cli/manager.rb
Overview
Manager for the CLI
Defined Under Namespace
Classes: ConfigLoader, DefaultConfigFileValue, DefaultPidFileValue, Error
Constant Summary
Constants included from ApplicationLoader
ApplicationLoader::LOADING_MESSAGE
Instance Method Summary collapse
-
#initialize(options) ⇒ Manager
constructor
A new instance of Manager.
-
#restart(stop_options, start_options) ⇒ Void
Restarts a daemonized worker.
-
#start(options) ⇒ Void
Starts a new worker.
-
#stop(options) ⇒ Void
Stops a daemonized worker.
Methods included from ApplicationLoader
#clear_application_loading_message, #different_time_zone?, #load_application, #print_time_zone_warning
Constructor Details
#initialize(options) ⇒ Manager
Returns a new instance of Manager.
16 17 18 |
# File 'lib/exekutor/internal/cli/manager.rb', line 16 def initialize() @global_options = end |
Instance Method Details
#restart(stop_options, start_options) ⇒ Void
Restarts a daemonized worker
70 71 72 73 |
# File 'lib/exekutor/internal/cli/manager.rb', line 70 def restart(, ) stop .merge(restart: true) start .merge(restart: true, daemonize: true) end |
#start(options) ⇒ Void
Starts a new worker
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/exekutor/internal/cli/manager.rb', line 29 def start() Process.setproctitle "Exekutor worker (Initializing…) [#{$PROGRAM_NAME}]" daemonize(restarting: [:restart]) if [:daemonize] load_application([:environment]) # Specify `yield: true` to prevent running in the context of the loaded module ActiveSupport.on_load(:exekutor, yield: true) do = ([:configfile], cli_worker_overrides()) ActiveSupport.on_load(:active_record, yield: true) do start_and_join_worker(, [:daemonize]) end end end |
#stop(options) ⇒ Void
Stops a daemonized worker
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/exekutor/internal/cli/manager.rb', line 47 def stop() daemon = Daemon.new(pidfile: pidfile) pid = daemon.pid if pid.nil? unless quiet? if [:restart] puts "Executor was not running" else puts "Executor is not running (pidfile not found at #{daemon.pidfile})" end end return elsif daemon.status? :not_running, :dead return end Process.kill("INT", pid) wait_for_process_end(daemon, pid, shutdown_timeout()) puts "Worker (PID: #{pid}) stopped." unless quiet? end |