Automatizacion Servicio NodeJS (Systemd) Debian/Ubuntu

is time to be a bash scripting....
ლ(¯ロ¯"ლ)
Post Reply
User avatar
Kosmito
Site Admin
Posts: 17
Joined: Mon Jan 09, 2023 7:16 pm
Contact:

Automatizacion Servicio NodeJS (Systemd) Debian/Ubuntu

Post by Kosmito »

Debemos crear el archivo en el sistema en debian es

Code: Select all

nano /etc/systemd/system/ejemplo.service
Luego debemos editar el usuario el puerto y la direccion de la app.js

Code: 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.target
En debian debemos hacer un Daemon reload

Code: Select all

systemctl daemon-reload
empezamos el proceso con

Code: Select all

systemctl start ejemplo
Si quieren que el servicio inicie al arranque del sistema deberan usar este comando

Code: Select all

systemctl enable ejemplo
Image
Image
Post Reply