Difference between revisions of "Systemd"

From Wasya Wiki
Jump to: navigation, search
(Read logs)
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
  
 
=== Start/stop/status ===
 
=== Start/stop/status ===
  service --status-all
+
 
  
 
   sudo systemctl start iro_get_chains.service
 
   sudo systemctl start iro_get_chains.service
 
   sudo systemctl status iro_get_chains.service
 
   sudo systemctl status iro_get_chains.service
 +
 +
=== Trash ===
 +
  service --status-all # does not work!
  
 
=== Read logs ===
 
=== Read logs ===
sudo journalctl -u stockwatcher.service
+
  journalctl -u stockwatcher.service
journalctl -u nginx.service
+
  journalctl -u nginx.service
 +
  journalctl -u iro_alert_stocks -n 100 -f
 +
 
 +
Limit how much logs journalctl keeps:
 +
 
 +
  journalctl --vacuum-time=2d
 +
  journalctl --vacuum-size=500M
  
 
=== Example service definition ===
 
=== Example service definition ===

Latest revision as of 04:59, 1 February 2024


they are in /etc/systemd/system/multi-user.target.wants

Start/stop/status

 sudo systemctl start iro_get_chains.service
 sudo systemctl status iro_get_chains.service

Trash

 service --status-all # does not work!

Read logs

 journalctl -u stockwatcher.service
 journalctl -u nginx.service
 journalctl -u iro_alert_stocks -n 100 -f

Limit how much logs journalctl keeps:

 journalctl --vacuum-time=2d
 journalctl --vacuum-size=500M

Example service definition

This is not up to date - look in the access repo pi/readme

[Unit]
Description=watch stocks

[Service]
Type=forking
WorkingDirectory=/home/ubuntu/projects/microsites3a/current
ExecStart=/home/ubuntu/.rbenv/shims/bundle exec rake ish_manager:stockwatcher
ExecStop=/bin/echo nothing
Restart=on-failure
Environment=RAILS_ENV=production
Environment=GMAIL_DOMAIN=gmail.com
Environment=GMAIL_USERNAME=<numeric-email>
Environment=GMAIL_PASSWORD=<password>

[Install]
WantedBy=multi-user.target