Framework updates
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
61
bin/ssr-server.js
Executable file
61
bin/ssr-server.js
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* RSpade SSR Server
|
||||
*
|
||||
* Thin wrapper around @jqhtml/ssr server.
|
||||
* Starts a long-running Node process that renders jqhtml components to HTML.
|
||||
* Managed by Rsx_SSR.php — spawned on-demand, communicates via Unix socket.
|
||||
*
|
||||
* Usage:
|
||||
* node system/bin/ssr-server.js --socket=/path/to/ssr-server.sock
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const { SSRServer } = require(path.join(__dirname, '..', 'node_modules', '@jqhtml', 'ssr', 'src', 'server.js'));
|
||||
|
||||
// Parse --socket argument
|
||||
let socketPath = null;
|
||||
for (let i = 2; i < process.argv.length; i++) {
|
||||
if (process.argv[i].startsWith('--socket=')) {
|
||||
socketPath = process.argv[i].split('=')[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!socketPath) {
|
||||
socketPath = path.join(__dirname, '..', 'storage', 'rsx-tmp', 'ssr-server.sock');
|
||||
}
|
||||
|
||||
const server = new SSRServer({
|
||||
maxBundles: 10,
|
||||
defaultTimeout: 30000
|
||||
});
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await server.listenUnix(socketPath);
|
||||
} catch (err) {
|
||||
console.error('[SSR] Failed to start:', err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
|
||||
// Ignore SIGHUP so server survives terminal disconnect
|
||||
process.on('SIGHUP', () => {});
|
||||
|
||||
process.on('SIGINT', async () => {
|
||||
await server.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await server.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
console.error('[SSR] Unhandled rejection:', err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error('[SSR] Uncaught exception:', err);
|
||||
});
|
||||
Reference in New Issue
Block a user