Modifying Systemd or Init script for Running Node.js (Express Framework)

Modifying Systemd or Init script for Running Node.js (Express Framework)

Things to remember.

Today, My developer told me to make such a configuration on a server that node application should start with NODE_ENV=production on our staging server.

I just took it lightly and thought that its to easy to do, even any guys have sound knowledge on Linux will think like that.

Stupid Steps (Wasted my couple of hours)

Step 1:

Just edited "/etc/systemd/system/node.service" and modified the changes by adding the "Environment=NODE_ENV=production" as below,

Step 2:

Quickly I have restarted the service by below command,

Result:

Failed to restart the service,

Note**:  node.service file is absolutely correct.

Culprit !!!

You just need to make sure before starting the node.js server, firstly create the fresh build from the code with below command,

not doing so, will keep you in trouble and “systemctl” will never start the node server.

Note**: I haven’t investigated that much from node.js side as what I found was seems to be related to some node.js dependencies in server.js file which was creating the issue, so comments are most welcome with a suitable explanation.

Askops
Askops
Developer: Nikhil raj
Price: Free

Leave a Reply