Class: Gemkeeper::ServerManager
- Inherits:
-
Object
- Object
- Gemkeeper::ServerManager
- Defined in:
- lib/gemkeeper/server_manager.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ ServerManager
constructor
A new instance of ServerManager.
- #running? ⇒ Boolean
- #start ⇒ Object
- #start_foreground ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config) ⇒ ServerManager
Returns a new instance of ServerManager.
10 11 12 |
# File 'lib/gemkeeper/server_manager.rb', line 10 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/gemkeeper/server_manager.rb', line 8 def config @config end |
Instance Method Details
#running? ⇒ Boolean
47 48 49 50 51 52 53 54 |
# File 'lib/gemkeeper/server_manager.rb', line 47 def running? return false unless File.exist?(config.pid_file) pid = read_pid return false unless pid process_alive?(pid) end |
#start ⇒ Object
14 15 16 17 18 |
# File 'lib/gemkeeper/server_manager.rb', line 14 def start ensure_not_running! generate_config_ru start_server end |
#start_foreground ⇒ Object
20 21 22 23 24 |
# File 'lib/gemkeeper/server_manager.rb', line 20 def start_foreground ensure_not_running! generate_config_ru start_server_foreground end |
#status ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/gemkeeper/server_manager.rb', line 39 def status if running? { running: true, pid: read_pid, url: config.geminabox_url } else { running: false } end end |
#stop ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gemkeeper/server_manager.rb', line 26 def stop raise ServerNotRunningError, "Server is not running" unless running? pid = read_pid Process.kill("TERM", pid) wait_for_process_exit(pid) cleanup_pid_file true rescue Errno::ESRCH cleanup_pid_file true end |