This adds: - Two entries in the manifest: - A choice for the NodeJS version - A port (provisionned in any case due to ynh limitations, but this should not matter) - Services and configs: - Systemctl configs to run the NodeJS server - A watcher service and path to restart NodeJS upon file update - A custom NGinx config because it is incompatible with the default one - Docs: - More info in the description and admin The install/remove/backup/restore have been adapted and tested. The upgrade script is updated but not tested The change_url script does not change It is not possible to have both PHP and NodeJS to keep the scripts simple.
19 lines
719 B
JavaScript
19 lines
719 B
JavaScript
const http = require('node:http');
|
|
const fs = require('fs');
|
|
const index = fs.readFileSync('index.html').toString();
|
|
|
|
const host = '127.0.0.1';
|
|
var port = process.env.PORT;
|
|
port = (typeof port !== 'undefined') ? port : 3000;
|
|
|
|
const file = index.replace("<hr/>", `<hr/> <h2> Port configuration </h2> <p>Your node application have to listen on port ${port}. Alternatively, you can get port var from envirronment with the following: </p> <pre> process.env.PORT; </pre>`);
|
|
|
|
const server = http.createServer((req, res) => {
|
|
res.statusCode = 200;
|
|
res.setHeader('Content-Type', 'text/html');
|
|
res.end(file);
|
|
});
|
|
|
|
server.listen(port, host, () => {
|
|
console.log('Web server running at http://%s:%s', host, port);
|
|
});
|