From 2b99e7e07ba46c03efd5994ed846eb39d1e0a528 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Fri, 13 Sep 2024 08:09:46 +0200 Subject: [PATCH] chore(systemd): add commands to reload units --- knowledge base/prometheus.md | 5 +++-- knowledge base/systemd.md | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/knowledge base/prometheus.md b/knowledge base/prometheus.md index c5cc0ca..55524f4 100644 --- a/knowledge base/prometheus.md +++ b/knowledge base/prometheus.md @@ -30,9 +30,10 @@ security policy. prometheus prometheus --web.enable-admin-api -# Reload the configuration file without restarting the process. +# Reload the configuration file *without* restarting the process. kill -s 'SIGHUP' '3969' pkill --signal 'HUP' 'prometheus' +curl -i -X 'POST' 'localhost:9090/-/reload' # if admin APIs are enabled # Shut down the process *gracefully*. kill -s 'SIGTERM' '3969' @@ -363,7 +364,7 @@ PUT /api/v1/admin/tsdb/snapshot URL query parameters: -- `skip_head`=: skip data present in the head block. Optional. +- `skip_head`=\: skip data present in the head block. Optional. Examples: diff --git a/knowledge base/systemd.md b/knowledge base/systemd.md index 5609126..48caef8 100644 --- a/knowledge base/systemd.md +++ b/knowledge base/systemd.md @@ -20,6 +20,9 @@ systemctl list-unit-files # List failed units only. systemctl list-units --state='failed' +# Reload service definitions. +systemctl daemon-reload + # Start services. sudo systemctl start 'adb.service' systemctl --user start 'keybase.service' @@ -28,6 +31,15 @@ systemctl --user start 'keybase.service' sudo systemctl restart 'bluetooth.service' systemctl --user restart 'davmail.service' +# Reload services. +sudo systemctl reload 'prometheus.service' +systemctl --user reload 'davmail.service' + +# Reload or restart services. +# For when one is unsure what would work. +sudo systemctl reload-or-restart 'apache2.service' +systemctl --user reload-or-restart 'davmail.service' + # Stop services. sudo systemctl stop 'cups.service' systemctl --user stop 'davmail.service' @@ -267,7 +279,9 @@ Storage=persistent ### Ignore the DNS servers list given by the DHCP server -Set the following lines in any network-specific file for which you want to ignore DNS servers from DHCP (like `/etc/systemd/network/eth0.network`), or in the global settings (`/etc/systemd/resolved.conf` or any file in `/etc/systemd/resolved.conf.d/`): +Set the following lines in any network-specific file for which you want to ignore DNS servers from DHCP (like +`/etc/systemd/network/eth0.network`), or in the global settings (`/etc/systemd/resolved.conf` or any file in +`/etc/systemd/resolved.conf.d/`): ```ini [DHCP] @@ -284,7 +298,9 @@ Use the handy command: sudo systemd-resolve -i 'wlp2s0' --set-dns '192.168.1.1' --set-domain 'lan' ``` -or set the following lines in the global settings (`/etc/systemd/resolved.conf` or any file in `/etc/systemd/resolved.conf.d/`), or in any network-specific file you want to set DNS servers for (like `/etc/systemd/network/eth0.network`): +or set the following lines in the global settings (`/etc/systemd/resolved.conf` or any file in +`/etc/systemd/resolved.conf.d/`), or in any network-specific file you want to set DNS servers for (like +`/etc/systemd/network/eth0.network`): ```ini [Resolve] @@ -307,6 +323,7 @@ Restart the `systemd-resolved` service to apply the new settings. - [How to Set Hostname Using Hostnamectl Command?] - [Suspend and hibernate] - [Changing DNS with systemd-resolved] +- [systemctl Commands: Restart, Reload, and Stop Service]