Class: MinioRunner::MinioServerManager
- Inherits:
-
Object
- Object
- MinioRunner::MinioServerManager
- Defined in:
- lib/minio_runner/minio_server_manager.rb
Constant Summary collapse
- SERVER_STOP_TIMEOUT_SECONDS =
5
Instance Attribute Summary collapse
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
9 10 11 |
# File 'lib/minio_runner/minio_server_manager.rb', line 9 def pid @pid end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
9 10 11 |
# File 'lib/minio_runner/minio_server_manager.rb', line 9 def process @process end |
Class Method Details
.log_file_path ⇒ Object
22 23 24 |
# File 'lib/minio_runner/minio_server_manager.rb', line 22 def log_file_path "#{MinioRunner.config.install_dir}/minio.log" end |
.start ⇒ Object
12 13 14 15 |
# File 'lib/minio_runner/minio_server_manager.rb', line 12 def start @server = new @server.start end |
.stop ⇒ Object
17 18 19 20 |
# File 'lib/minio_runner/minio_server_manager.rb', line 17 def stop return if @server.nil? @server.stop end |
Instance Method Details
#process_exited? ⇒ Boolean
69 70 71 |
# File 'lib/minio_runner/minio_server_manager.rb', line 69 def process_exited? @process.nil? || @process.exited? end |
#process_running? ⇒ Boolean
65 66 67 |
# File 'lib/minio_runner/minio_server_manager.rb', line 65 def process_running? defined?(@process) && @process&.alive? end |
#start ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/minio_runner/minio_server_manager.rb', line 27 def start if process_running? MinioRunner.logger.debug("Already started minio server.") return end MinioRunner.logger.debug("Starting minio server...") MinioRunner::System.exit_hook { stop } @process = MinioRunner::ChildProcess.build( server_command, env: { "MINIO_ROOT_USER" => MinioRunner.config.minio_root_user, "MINIO_ROOT_PASSWORD" => MinioRunner.config.minio_root_password, "MINIO_DOMAIN" => MinioRunner.config.minio_domain, }, log_file: MinioServerManager.log_file_path, ) @process.start # Make sure the minio server is ready to accept requests. MinioRunner::MinioHealthCheck.call(retries: 2) MinioRunner.logger.debug("minio server running at pid #{@process.pid}!") end |
#stop ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/minio_runner/minio_server_manager.rb', line 56 def stop return if process_exited? MinioRunner.logger.debug("Stopping minio server running at pid #{@pid}...") @process.stop(SERVER_STOP_TIMEOUT_SECONDS) @process = nil MinioRunner.logger.debug("minio server stopped") end |