Class: ReactOnRails::Dev::ProcessManager
- Inherits:
-
Object
- Object
- ReactOnRails::Dev::ProcessManager
- 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- ENV_KEYS_TO_PRESERVE =
Env vars set after Bundler.setup that must survive with_unbundled_env. with_unbundled_env restores the pre-Bundler env snapshot, so any var set at runtime (e.g. PORT by PortSelector) is lost. We capture them before entering the block and pass them explicitly to system(). This follows the same pattern used by Rails’ bundle_command (railties), Spring’s process spawning, and this codebase’s own PackGenerator.
%w[PORT SHAKAPACKER_DEV_SERVER_PORT].freeze
Class Method Summary collapse
- .ensure_procfile(procfile) ⇒ Object
-
.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.
- .run_with_process_manager(procfile) ⇒ Object
Class Method Details
.ensure_procfile(procfile) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/react_on_rails/dev/process_manager.rb', line 26 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
22 23 24 |
# File 'lib/react_on_rails/dev/process_manager.rb', line 22 def installed?(process) installed_in_current_context?(process) end |
.run_with_process_manager(procfile) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/react_on_rails/dev/process_manager.rb', line 36 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 # run_process_if_available returns: # - true/false (exit status) if process was found and executed # - nil if process was not found overmind_result = run_process_if_available("overmind", ["start", "-f", procfile]) return if overmind_result == true # Overmind ran successfully foreman_result = run_process_if_available("foreman", ["start", "-f", procfile]) return if foreman_result == true # Foreman ran successfully # If either process was found but exited with error, don't show "not found" message # The process manager itself will have shown its own error message exit 1 if overmind_result == false || foreman_result == false # Neither process manager was found show_process_manager_installation_help exit 1 end |