user:kluong:running_a_service_in_production

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
user:kluong:running_a_service_in_production [2022/10/07 17:23]
kluong [Deployments and version control]
user:kluong:running_a_service_in_production [2022/10/12 18:20] (current)
kluong
Line 18: Line 18:
  
 As part of running a service in production, you want to make sure that the service stays up so it's important to use something like systemd to manage this. As part of running a service in production, you want to make sure that the service stays up so it's important to use something like systemd to manage this.
 +
 +Here's an example of a very simple systemd service file:
 +
 +<​code>​
 +[Unit]
 +Description=Example app
 +After=network.target
 +
 +[Service]
 +Type=simple
 +User=scel
 +WorkingDirectory=/​home/​example-user/​example-app
 +ExecStart=/​home/​example-user/​example-app/​run.sh --some-flag
 +Restart=always
 +
 +[Install]
 +WantedBy=multi-user.target
 +</​code>​
 +
 +This could be installed in `/​etc/​systemd/​system/​example-app.service`
 +
 +After installing it, you can reload the config:
 +
 +<​code>​
 +systemctl daemon-reload
 +systemctl start example-app.service
 +</​code>​
  
  
Line 27: Line 54:
 Deployments should be tied to some sort of version control (like git), or some sort of artifact repository like debian repositories. You want to avoid having deployment be freely editable by anyone with access to the machine, since changes will be hard to if not difficult to track. ​ Deployments should be tied to some sort of version control (like git), or some sort of artifact repository like debian repositories. You want to avoid having deployment be freely editable by anyone with access to the machine, since changes will be hard to if not difficult to track. ​
  
-{{ :​user:​kluong:​codebase-deploys.png?​200| }} +{{ :​user:​kluong:​codebase-deploys.png?​200 |}}
- +
  
  
  • user/kluong/running_a_service_in_production.1665163389.txt.gz
  • Last modified: 2022/10/07 17:23
  • by kluong