Module: Lich::Common::SessionLauncher

Defined in:
documented/common/session_launcher.rb

Constant Summary collapse

OPTIONAL_PATH_FLAGS =
[
  { option: 'home', key: :home_dir, constant: :LICH_DIR },
  { option: 'data', key: :data_dir, constant: :DATA_DIR },
  { option: 'scripts', key: :script_dir, constant: :SCRIPT_DIR },
  { option: 'temp', key: :temp_dir, constant: :TEMP_DIR },
  { option: 'maps', key: :map_dir, constant: :MAP_DIR },
  { option: 'logs', key: :log_dir, constant: :LOG_DIR },
  { option: 'backup', key: :backup_dir, constant: :BACKUP_DIR },
  { option: 'lib', key: :lib_dir, constant: :LIB_DIR }
].freeze

Class Method Summary collapse

Class Method Details

.launch(launch_data, launch_context: nil) ⇒ Hash

Launches a new session process with the given launch data.

Examples:

Launch a session

result = Lich::Common::SessionLauncher.launch(['--option', 'value'])

Parameters:

  • launch_data (Array)

    an array of data required to launch the session

  • launch_context (Hash, nil) (defaults to: nil)

    optional context for the launch

Returns:

  • (Hash)

    result of the launch operation, including success status and process ID

Raises:

  • (ArgumentError)

    if launch_data is not a non-empty array



32
33
34
35
36
37
38
39
40
41
# File 'documented/common/session_launcher.rb', line 32

def launch(launch_data, launch_context: nil)
  unless launch_data.is_a?(Array) && launch_data.any?
    return { ok: false, error: 'launch_data must be a non-empty Array' }
  end

  pid = spawn_process(launch_data, launch_context: launch_context)
  { ok: true, pid: pid }
rescue StandardError => e
  { ok: false, error: e.message }
end