35 lines
873 B
Bash

#!/bin/bash
# Install NodeJS
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Place app.js
cd ~/
mkdir tmpNodeApp/
cd tmpNodeApp/
nano app.js
# Start a node process
node app.js
# Check to see if it's working properly in another shell
curl http://localhost:5000
sudo lsof -i -P -n | grep 5000
# Stop process, perform check again
# Create the service file along with running other systemd commands
sudo nano /etc/systemd/system/test-node-process.service
sudo systemctl daemon-reload
sudo systemctl enable --now test-node-process
# Some more typical systemd commands
# sudo systemctl status test-node-process
# sudo systemctl enable test-node-process
# sudo systemctl disable test-node-process
# sudo systemctl start test-node-process
# sudo systemctl stop test-node-process
# sudo systemctl restart test-node-process