Files
cloud-node-container/examples/simple-website/server.js
jknapp 68ef106277
Some checks failed
Cloud Node Container / Build-and-Push (18) (push) Successful in 1m52s
Cloud Node Container / Build-and-Push (22) (push) Has been cancelled
Cloud Node Container / Build-and-Push (20) (push) Has been cancelled
Fix PM2 cluster mode and user permission errors
- Force PM2 to use fork mode instead of cluster mode
- Disable wait_ready to avoid startup issues
- Add PM2 ready signal to simple-website server
- Add PM2 status check after startup
- Set NODE_ENV=production for PM2 startup

The cluster mode was causing the UID 1002 error. Fork mode runs
the process directly as the specified user without additional
permission complications.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 09:53:01 -07:00

33 lines
834 B
JavaScript

const express = require('express');
const path = require('path');
const app = express();
const port = process.env.PORT || 3000;
// Serve static files from public directory
app.use(express.static('public'));
// Basic routes
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
app.get('/about', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'about.html'));
});
app.get('/contact', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'contact.html'));
});
// Health check for the container
app.get('/ping', (req, res) => {
res.json({ status: 'ok', timestamp: new Date().toISOString() });
});
app.listen(port, () => {
console.log(`Simple website running on port ${port}`);
// Send ready signal to PM2
if (process.send) {
process.send('ready');
}
});