Starting Services
Sometimes you need to keep that terrible python server that you have built from my last post running. Or you have a better built server and you want to get up an running. Let me introduce you to the world of services!
$ man systemctl
SYSTEMCTL(1) systemctl SYSTEMCTL(1)
NAME
systemctl - Control the systemd system and service manager
.
.
.
This is a tool on linux to help you manage your services.
A Service is a program that runs in the background outside of the interactive control of system users. Useful for running things like api's.
Steps:
- Go to folder with all the services:
- Make a file with your service, mine will be an 'api'
- Write your service file
- Then reload the dameon
- Start the service
- Check if it is active
$ cd /etc/systemd/system
$ vim api.service
$ vim api.service
[Unit]
Description=API for Senior Project
[Service]
User=root
WorkingDirectory=/root/api3
ExecStart=/usr/local/bin/flask --app main run --host=0.0.0.0
Restart=always
[Install]
WantedBy=multi-user.target
$ systemctl daemon-reload
$ start api.service
$ systemctl status api.service