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 28: Line 55:
  
 {{ :​user:​kluong:​codebase-deploys.png?​200 |}} {{ :​user:​kluong:​codebase-deploys.png?​200 |}}
- 
- 
  
  
  • user/kluong/running_a_service_in_production.1665163420.txt.gz
  • Last modified: 2022/10/07 17:23
  • by kluong