Automatizacion Servicio NodeJS (Systemd) Debian/Ubuntu
Posted: Fri Jan 13, 2023 6:37 pm
Debemos crear el archivo en el sistema en debian es
Luego debemos editar el usuario el puerto y la direccion de la app.js
En debian debemos hacer un Daemon reload
empezamos el proceso con
Si quieren que el servicio inicie al arranque del sistema deberan usar este comando
Code: Select all
nano /etc/systemd/system/ejemplo.serviceCode: Select all
[Unit]
Description=hello_env.js - making your environment variables rad
Documentation=https://example.com
After=network.target
[Service]
Environment=NODE_PORT=3001
Type=simple
User=ubuntu
ExecStart=/usr/bin/node /home/ubuntu/app.js
Restart=on-failure
[Install]
WantedBy=multi-user.targetCode: Select all
systemctl daemon-reloadCode: Select all
systemctl start ejemploCode: Select all
systemctl enable ejemplo