File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
src/BenchmarksApps/TechEmpower/nextjs Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -33,13 +33,27 @@ if (!dev) {
33
33
//console.log(`server.js found at: ${server}`);
34
34
35
35
if ( cluster . isPrimary ) {
36
- console . log ( `Primary ${ process . pid } is running ` ) ;
36
+ console . log ( `Primary is running on process ${ process . pid } ` ) ;
37
37
38
+ cluster . setupPrimary ( { silent : true } ) ;
38
39
const numCPUs = os . cpus ( ) . length ;
39
40
40
41
// Fork workers
42
+ let listening = 0 ;
41
43
for ( let i = 0 ; i < numCPUs ; i ++ ) {
42
- cluster . fork ( ) ;
44
+ const w = cluster . fork ( ) ;
45
+ w . process . stdout ?. on ( 'data' , ( chunk ) => {
46
+ const msg = chunk . toString ( ) . trim ( ) ;
47
+ if ( msg . startsWith ( 'Listening on port' ) ) {
48
+ listening ++ ;
49
+ console . log ( `Worker ${ listening } of ${ numCPUs } on process ${ w . process . pid } : ${ msg } ` ) ;
50
+ if ( listening == numCPUs ) {
51
+ console . log ( 'All workers listening.' ) ;
52
+ }
53
+ } else {
54
+ console . log ( `Worker ${ w . id } : ${ msg } ` )
55
+ }
56
+ } ) ;
43
57
}
44
58
45
59
cluster . on ( 'exit' , ( worker , code , signal ) => {
You can’t perform that action at this time.
0 commit comments