Welcome to Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy

Process Manager for Amazon Linux 2023 for Node.Js Project

For Amazon Linux 2023, the recommended way to run and manage a Node.js app in production is using systemd — the native process manager and service controller built into modern Linux distributions (including Amazon Linux 2023).

Why systemd?

✅ Preinstalled and supported on Amazon Linux 2023
✅ Automatically starts on boot
✅ Logs to journalctl
✅ No need to install PM2 or forever

Here’s how to set it up for your Node.js project:

✅ Step-by-Step: Run a Node.js App with systemd on Amazon Linux 2023

1. Install Node.js (if not already installed)

If you haven’t installed Node.js yet:

bash
				
					curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
sudo yum install -y nodejs

				
			

Verify:

bash
				
					node -v
npm -v
				
			

2. Create a systemd service file

Let’s say your app is located at:

/home/ec2-user/myapp/app.js

Create a new service:

bash
				
					sudo nano /etc/systemd/system/myapp.service
				
			

Paste the following (replace paths/user accordingly):

ini
				
					[Unit]
Description=My Node.js App
After=network.target

[Service]
ExecStart=/usr/bin/node /home/ec2-user/myapp/app.js
WorkingDirectory=/home/ec2-user/myapp
Restart=always
RestartSec=5
Environment=NODE_ENV=production
User=ec2-user
Group=ec2-user

[Install]
WantedBy=multi-user.target
				
			
Save and exit.

3. Reload systemd and enable your service

bash
				
					sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable myapp
sudo systemctl start myapp
				
			

4. Check if your app is running

bash
				
					sudo systemctl status myapp
				
			

🔍 View logs:

bash
				
					journalctl -u myapp -f
				
			

(Press Ctrl+C to exit)

5. Manage the app

  • Restart: sudo systemctl restart myapp

  • Stop: sudo systemctl stop myapp

  • View logs: journalctl -u myapp

✅ Done! Your Node.js app will now auto-start on boot and stay running with systemd.

Drop your queries

Table of Contents

Have A Project In Mind? Let's Get To Work