Skip to main content
Notice removed Draw attention by CommunityBot
Bounty Ended with no winning answer by CommunityBot
retitle more specifically
Link
mmw
  • 111
  • 8

systemd exits Node appcreate-react-app

Notice added Draw attention by mmw
Bounty Started worth 50 reputation by mmw
added 1208 characters in body; edited title
Source Link
mmw
  • 111
  • 8

systemd exits Node app through systemd goes inactive

I am trying to use a systemd service to run a Node app (specifically, a React app generated with create-react-app. I put a file frontend.service at /etc/systemd/system/ with (minimally) these contents:

[Unit]
Description=React Web Application

[Service]
ExecStart=/usr/local/bin/npm start --prefix=<path to app>

[Install]
WantedBy=multi-user.target

After starting the service, my browser shows the nginx bad gateway error, and ps aux | grep node shows no corresponding process. The last lineoutput of journalctl -u frontend reports successful steps like "Started React Web Application" and eventually "Starting development server...". However, systemctl status frontend reports that the service is loaded but inactive/dead (edit: or, active/exited).

I tried some adjustments to the .service file, in particular Type=forking, RemainAfterExit=true, and KillMode=process. But the problem persists. What is going on? How to fix this?

The app does work fine if I run it directly using npm start in the shell. Also, another (non-node) web server works fine running through a similar systemd script.

Here is the systemctl status output:

wm-frontend.service - React Web Application
   Loaded: loaded (/etc/systemd/system/wm-frontend.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2020-08-10 14:40:59 UTC; 32min ago
  Process: 4033 ExecStart=/usr/local/bin/npm start --prefix=/home/mw/wm-ax/frontend/blog --scripts-prepend-node-path (code=exited, status=0/SUCCESS)
 Main PID: 4033 (code=exited, status=0/SUCCESS)

Aug 10 14:40:59 localhost systemd[1]: Started React Web Application.
Aug 10 14:41:00 localhost npm[4033]: > [email protected] start /home/mw/wm-ax/frontend/blog
Aug 10 14:41:00 localhost npm[4033]: > react-scripts start
Aug 10 14:41:04 localhost npm[4033]: ℹ 「wds」: Project is running at http://0.0.0.0:3000/
Aug 10 14:41:04 localhost npm[4033]: ℹ 「wds」: webpack output is served from
Aug 10 14:41:04 localhost npm[4033]: ℹ 「wds」: Content not from webpack is served from /home/mw/wm-ax/frontend/blog/public
Aug 10 14:41:04 localhost npm[4033]: ℹ 「wds」: 404s will fallback to /
Aug 10 14:41:04 localhost npm[4033]: Starting the development server...

Node app through systemd goes inactive

I am trying to use a systemd service to run a Node app (specifically, a React app generated with create-react-app. I put a file frontend.service at /etc/systemd/system/ with (minimally) these contents:

[Unit]
Description=React Web Application

[Service]
ExecStart=/usr/local/bin/npm start --prefix=<path to app>

[Install]
WantedBy=multi-user.target

After starting the service, my browser shows the nginx bad gateway error, and ps aux | grep node shows no corresponding process. The last line of journalctl -u frontend reports "Started React Web Application". However, systemctl status frontend reports that the service is loaded but inactive/dead.

I tried some adjustments to the .service file, in particular Type=forking, RemainAfterExit=true, and KillMode=process. But the problem persists. What is going on? How to fix this?

The app does work fine if I run it directly using npm start in the shell. Also, another (non-node) web server works fine running through a similar systemd script.

systemd exits Node app

I am trying to use a systemd service to run a Node app (specifically, a React app generated with create-react-app. I put a file frontend.service at /etc/systemd/system/ with (minimally) these contents:

[Unit]
Description=React Web Application

[Service]
ExecStart=/usr/local/bin/npm start --prefix=<path to app>

[Install]
WantedBy=multi-user.target

After starting the service, my browser shows the nginx bad gateway error, and ps aux | grep node shows no corresponding process. The output of journalctl -u frontend reports successful steps like "Started React Web Application" and eventually "Starting development server...". However, systemctl status frontend reports that the service is loaded but inactive/dead (edit: or, active/exited).

I tried some adjustments to the .service file, in particular Type=forking, RemainAfterExit=true, and KillMode=process. But the problem persists. What is going on? How to fix this?

The app does work fine if I run it directly using npm start in the shell. Also, another (non-node) web server works fine running through a similar systemd script.

Here is the systemctl status output:

wm-frontend.service - React Web Application
   Loaded: loaded (/etc/systemd/system/wm-frontend.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2020-08-10 14:40:59 UTC; 32min ago
  Process: 4033 ExecStart=/usr/local/bin/npm start --prefix=/home/mw/wm-ax/frontend/blog --scripts-prepend-node-path (code=exited, status=0/SUCCESS)
 Main PID: 4033 (code=exited, status=0/SUCCESS)

Aug 10 14:40:59 localhost systemd[1]: Started React Web Application.
Aug 10 14:41:00 localhost npm[4033]: > [email protected] start /home/mw/wm-ax/frontend/blog
Aug 10 14:41:00 localhost npm[4033]: > react-scripts start
Aug 10 14:41:04 localhost npm[4033]: ℹ 「wds」: Project is running at http://0.0.0.0:3000/
Aug 10 14:41:04 localhost npm[4033]: ℹ 「wds」: webpack output is served from
Aug 10 14:41:04 localhost npm[4033]: ℹ 「wds」: Content not from webpack is served from /home/mw/wm-ax/frontend/blog/public
Aug 10 14:41:04 localhost npm[4033]: ℹ 「wds」: 404s will fallback to /
Aug 10 14:41:04 localhost npm[4033]: Starting the development server...
added 90 characters in body
Source Link
mmw
  • 111
  • 8

I am trying to use a systemd service to run a Node app (specifically, a React app generated with create-react-app. I put a file frontend.service at /etc/systemd/system/ with (minimally) these contents:

[Unit]
Description=React Web Application

[Service]
ExecStart=/usr/local/bin/npm start --prefix=<path to app>

[Install]
WantedBy=multi-user.target

After starting the service, my browser shows the nginx bad gateway error, and ps aux | grep node shows no corresponding process. The last line of journalctl -u frontend reports "Started React Web Application". However, systemctl status frontend reports that the service is loaded but inactive/dead.

I tried some adjustments to the .service file, in particular Type=forking, RemainAfterExit=true, and KillMode=process. But the problem persists. What is going on? How to fix this?

The app does work fine if I run it directly using npm start in the shell. Also, another (non-node) web server works fine running through a similar systemd script.

I am trying to use a systemd service to run a Node app (specifically, a React app generated with create-react-app. I put a file frontend.service at /etc/systemd/system/ with (minimally) these contents:

[Unit]
Description=React Web Application

[Service]
ExecStart=/usr/local/bin/npm start --prefix=<path to app>

[Install]
WantedBy=multi-user.target

After starting the service, my browser shows the nginx bad gateway error, and ps aux | grep node shows no corresponding process. The last line of journalctl -u frontend reports "Started React Web Application". However, systemctl status frontend reports that the service is loaded but inactive/dead.

I tried some adjustments to the .service file, in particular Type=forking, RemainAfterExit=true, and KillMode=process. But the problem persists. What is going on? How to fix this?

The app does work fine if I run it directly using npm start in the shell.

I am trying to use a systemd service to run a Node app (specifically, a React app generated with create-react-app. I put a file frontend.service at /etc/systemd/system/ with (minimally) these contents:

[Unit]
Description=React Web Application

[Service]
ExecStart=/usr/local/bin/npm start --prefix=<path to app>

[Install]
WantedBy=multi-user.target

After starting the service, my browser shows the nginx bad gateway error, and ps aux | grep node shows no corresponding process. The last line of journalctl -u frontend reports "Started React Web Application". However, systemctl status frontend reports that the service is loaded but inactive/dead.

I tried some adjustments to the .service file, in particular Type=forking, RemainAfterExit=true, and KillMode=process. But the problem persists. What is going on? How to fix this?

The app does work fine if I run it directly using npm start in the shell. Also, another (non-node) web server works fine running through a similar systemd script.

add another solution attempt
Source Link
mmw
  • 111
  • 8
Loading
Source Link
mmw
  • 111
  • 8
Loading