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:

  1. Go to folder with all the services:
  2. $ cd /etc/systemd/system
  3. Make a file with your service, mine will be an 'api'
  4. $ vim api.service
  5. Write your service file
  6. $ 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
  7. Then reload the dameon
  8. $ systemctl daemon-reload
  9. Start the service
  10. $ start api.service
  11. Check if it is active
  12. $ systemctl status api.service