Created
February 23, 2023 12:37
-
-
Save zaheeraws/15d3639ed0cb88838ead76e8df806ca0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script.sh | |
#! /bin/bash | |
source ${HOME}/.bashrc | |
cd /absolute/path/to/my/project | |
export NODE_ENV=development | |
npm start | |
Now change it's mode to be executable | |
chmod +x script.sh | |
Now we can create our service (located for instance in /etc/systemd/system/my-project.service) | |
my-project.service | |
[Unit] | |
Description=My Project | |
After=syslog.target network.target | |
[Service] | |
Type=simple | |
Restart=always | |
RestartSec=1 | |
ExecStart=/path/to/my/script.sh | |
User=root | |
[Install] | |
WantedBy=multi-user.target | |
And now let's run it and enable it | |
systemctl start my-project | |
systemctl enable my-project |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment