Answer the question
In order to leave comments, you need to log in
How to run an Express application on a server via systemd?
There is a server on ubuntu 16. There is an application on express. I want to run the daemon through systemd so that the application is constantly spinning on the server.
My actions:
- Created a test user test
- Put the project in the /home/test/backend folder
- Created the file /etc/systemd/system/backend.service
Here are the contents of the file:
[Unit]
Description= backend
[Service]
Type=simple
ExecStart=/home/test/backend/bin/www
Restart=always
WorkingDirectory=/backend/bin
User=test
Group=test
# Environment variables:
Environment=NODE_ENV=production
# Allow many incoming connections
LimitNOFILE=infinity
# Allow core dumps for debugging
LimitCORE=infinity
StandardInput=null
StandardOutput=syslog
StandardError=syslog
Restart=always
[Install]
WantedBy=multi-user.target
# systemctl enable backend
# systemctl start backend
● backend.service - backend
Loaded: loaded (/etc/systemd/system/backend.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Wed 2017-08-16 02: 44:59 EDT; 7min ago
Process: 27723 ExecStart=/home/test/backend/bin/www (code=exited, status=200/CHDIR)
Main PID: 27723 (code=exited, status=200/CHDIR)
Aug 16 02:44:59 vps131133.vps.ovh.ca systemd[1]: backend.service: Service hold-off time over, scheduling restart.
Aug 16 02:44:59 vps131133.vps.ovh.ca systemd[1]: Stopped backend.
Aug 16 02:44:59 vps131133.vps.ovh.ca systemd[1]: backend.service: Start request repeated too quickly.
Aug 16 02:44:59 vps131133.vps.ovh.ca systemd[1]: Failed to start backend.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question