File tree Expand file tree Collapse file tree 2 files changed +32
-12
lines changed
packages/node-renderer/src Expand file tree Collapse file tree 2 files changed +32
-12
lines changed Original file line number Diff line number Diff line change @@ -7,5 +7,28 @@ class Engine < Rails::Engine
77 initializer "react_on_rails_pro.routes" do
88 ActionDispatch ::Routing ::Mapper . include ReactOnRailsPro ::Routes
99 end
10+
11+ # Validate license on Rails startup
12+ # This ensures the application fails fast if the license is invalid or missing
13+ initializer "react_on_rails_pro.validate_license" , before : :load_config_initializers do
14+ config . after_initialize do
15+ # Skip license validation during asset precompilation
16+ next if defined? ( Rake ) && Rake ::Task . task_defined? ( "assets:precompile" )
17+
18+ # Skip license validation when running RSpec tests
19+ # Tests mock the license validation with stub keys
20+ next if defined? ( RSpec )
21+
22+ Rails . logger . info "[React on Rails Pro] Validating license..."
23+
24+ if ReactOnRailsPro ::LicenseValidator . valid?
25+ Rails . logger . info "[React on Rails Pro] License validation successful"
26+ else
27+ # License validation will raise an error, so this line won't be reached
28+ # But we include it for clarity
29+ Rails . logger . error "[React on Rails Pro] License validation failed"
30+ end
31+ end
32+ end
1033 end
1134end
Original file line number Diff line number Diff line change @@ -12,22 +12,19 @@ import { isLicenseValid, getLicenseValidationError } from './shared/licenseValid
1212const MILLISECONDS_IN_MINUTE = 60000 ;
1313
1414export = function masterRun ( runningConfig ?: Partial < Config > ) {
15- // Validate license before starting
15+ // Validate license before starting - required in all environments
16+ log . info ( '[React on Rails Pro] Validating license...' ) ;
17+
1618 if ( ! isLicenseValid ( ) ) {
1719 const error = getLicenseValidationError ( ) || 'Invalid license' ;
18- const isDevelopment = process . env . NODE_ENV === 'development' || process . env . NODE_ENV === 'test' ;
19-
20- if ( isDevelopment ) {
21- log . warn ( `[React on Rails Pro] ${ error } ` ) ;
22- // Continue in development with warning
23- } else {
24- log . error ( `[React on Rails Pro] ${ error } ` ) ;
25- process . exit ( 1 ) ;
26- }
27- } else {
28- log . info ( '[React on Rails Pro] License validation successful' ) ;
20+ log . error ( `[React on Rails Pro] ${ error } ` ) ;
21+ // License validation already calls process.exit(1) in handleInvalidLicense
22+ // But we add this for safety in case the validator changes
23+ process . exit ( 1 ) ;
2924 }
3025
26+ log . info ( '[React on Rails Pro] License validation successful' ) ;
27+
3128 // Store config in app state. From now it can be loaded by any module using getConfig():
3229 const config = buildConfig ( runningConfig ) ;
3330 const { workersCount, allWorkersRestartInterval, delayBetweenIndividualWorkerRestarts } = config ;
You can’t perform that action at this time.
0 commit comments