F
F
fr0zen2017-08-16 09:54:24
ubuntu
fr0zen, 2017-08-16 09:54:24

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

- Further commands:
# systemctl enable backend
# systemctl start backend

- Then, after the systemctl status backend command, I get the following:
● 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.

What could I be missing? Tell me plz.
PS When manually launched, the application itself works fine. I run on node ./bin/www

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-08-16
@fr0zen

I run on node ./bin/www

ExecStart= node /home/test/backend/bin/www

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question