Class: ReactOnRails::Dev::ProcessManager

Inherits:
Object
  • Object
show all
Defined in:
lib/react_on_rails/dev/process_manager.rb

Constant Summary collapse

VERSION_CHECK_TIMEOUT =

Timeout for version check operations to prevent hanging

5

Class Method Summary collapse

Class Method Details

.ensure_procfile(procfile) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/react_on_rails/dev/process_manager.rb', line 18

def ensure_procfile(procfile)
  return if File.exist?(procfile)

  warn <<~MSG
    ERROR:
    Please ensure `#{procfile}` exists in your project!
  MSG
  exit 1
end

.installed?(process) ⇒ Boolean

Check if a process is available and usable in the current execution context This accounts for bundler context where system commands might be intercepted

Returns:

  • (Boolean)


14
15
16
# File 'lib/react_on_rails/dev/process_manager.rb', line 14

def installed?(process)
  installed_in_current_context?(process)
end

.run_with_process_manager(procfile) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/react_on_rails/dev/process_manager.rb', line 28

def run_with_process_manager(procfile)
  # Validate procfile path for security
  unless valid_procfile_path?(procfile)
    warn "ERROR: Invalid procfile path: #{procfile}"
    exit 1
  end

  # Clean up stale files before starting
  FileManager.cleanup_stale_files

  # Try process managers in order of preference
  return if run_process_if_available("overmind", ["start", "-f", procfile])
  return if run_process_if_available("foreman", ["start", "-f", procfile])

  show_process_manager_installation_help
  exit 1
end