You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (isMainThread) {
/* The acceptorApp only listens, but must be SSL if worker apps are SSL and likewise opposite */
const acceptorApp = uWS.SSLApp({
key_file_name: 'misc/key.pem',
cert_file_name: 'misc/cert.pem',
passphrase: '1234'
}).listen(port, (token) => {
if (token) {
console.log('Listening to port ' + port + ' from thread ' + threadId + ' as main acceptor');
} else {
console.log('Failed to listen to port ' + port + ' from thread ' + threadId);
}
});
/* Main thread loops over all CPUs */
/* In this case we only spawn two (hardcoded) */
/*os.cpus()*/[0, 1].forEach(() => {
/* Spawn a new thread running this source file */
new Worker(__filename).on("message", (workerAppDescriptor) => {
acceptorApp.addChildAppDescriptor(workerAppDescriptor);
});
});
/* I guess main thread joins by default? */
} else {
/* Here we are inside a worker thread */
const app = uWS.SSLApp({
key_file_name: 'misc/key.pem',
cert_file_name: 'misc/cert.pem',
passphrase: '1234'
}).get('/*', (res, req) => {
res.end('Hello Worker!');
}).listen(4000, (token) => {
if (token) {
console.log('Listening to port ' + 4000 + ' from thread ' + threadId);
} else {
console.log('Failed to listen to port ' + 4000 + ' from thread ' + threadId);
}
});
/* The worker sends back its descriptor to the main acceptor */
parentPort.postMessage(app.getDescriptor());
}
Testing on ubuntu 24.04
The text was updated successfully, but these errors were encountered:
code like this:
Testing on ubuntu 24.04
The text was updated successfully, but these errors were encountered: