-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-renderer.js
More file actions
51 lines (36 loc) · 1.71 KB
/
node-renderer.js
File metadata and controls
51 lines (36 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
const path = require('path');
const { env } = process;
const { reactOnRailsProNodeRenderer } = require('react-on-rails-pro-node-renderer');
const config = {
// Path to store server bundles cache
serverBundleCachePath: path.resolve(__dirname, '.node-renderer-bundles'),
// Listen at RENDERER_PORT env value or default port 3800
port: env.RENDERER_PORT || 3800,
// Log level: 'debug', 'info', 'warn', 'error'
logLevel: env.RENDERER_LOG_LEVEL || 'info',
// Password for authentication (should match react_on_rails_pro.rb config)
// In production, use environment variables
password: env.RENDERER_PASSWORD || 'development_password',
// Number of worker processes (defaults to CPU count - 1)
workersCount: env.RENDERER_WORKERS_COUNT ? parseInt(env.RENDERER_WORKERS_COUNT, 10) : 2,
// Time in minutes between restarting all workers (to clear memory leaks)
allWorkersRestartInterval: env.RENDERER_ALL_WORKERS_RESTART_INTERVAL || 60,
// Time in minutes between each worker restarting when restarting all workers
delayBetweenIndividualWorkerRestarts: 1,
// Enable NodeJS modules support in the VM context
// Required for loadable components and async operations
supportModules: true,
// Additional NodeJS modules to add to the VM context
additionalContext: { URL, AbortController, performance },
// Set to false to use real timers (required for setTimeout, setInterval)
stubTimers: false,
// Replay console logs from async server operations
replayServerAsyncOperationLogs: true,
};
// Reduce workers in CI environment
if (env.CI) {
config.workersCount = 2;
config.allWorkersRestartInterval = 2;
config.delayBetweenIndividualWorkerRestarts = 0.01;
}
reactOnRailsProNodeRenderer(config);