Improve nodejs admin doc

This commit is contained in:
Antoine Lima 2024-03-10 22:56:27 +01:00
parent a28c27e3c4
commit 536b1fbc8b
No known key found for this signature in database
GPG key ID: 5D1E65E3DEB73410

View file

@ -30,6 +30,15 @@ Once logged in, under the Web directory you will see a `www` folder which contai
If you want to add tweak the nginx configuration for this app, it is recommended to edit `/etc/nginx/conf.d/__DOMAIN__.d/__ID__.d/WHATEVER_NAME.conf` (ensure that the file has the `.conf` extension) and reload the nginx after making sure that the configuration is valid using `nginx -t`.
### Listening the right port for NodeJS
{% if nodeversion != 'none' %}
The listen port is available to the node process throught the environment variable `PORT`. Make sure that your main `.js` file retrieves it with `process.env.PORT` as its value is not predictable.
### Interfacing with NodeJS
A `package.json` should be available within the `/var/www/__APP__/www`. It is used to `npm install`, `npm run build` then `npm run start`. As such, it should at least define the dependencies and provide the `build` and `install` scripts.
You should then start a server in `/var/www/__APP__/www/index.js`.
It should listen on the port provided through the `PORT` environment with `process.env.PORT` or statically with __PORT__.
The server should reload its files after they change, but due to systemd's limitations, it only works for top level folders/files.
If your server does not display the right things, restart the `__APP__-nodejs` service.
{% endif %}