Check config before systemctl reload

Currently systemd does not support seperate ExecReloadPre command to
check if safe reload is possible.[0] It should be possible to emulate
similar behavior with multible ExecPreload lines but due to systemd
issue #11238 it is not currently possible.[1]

Current workaround is to tell systemd to ignore ExecReload command exit
code and put a oneliner shell script in there that checks if its safe to
reload nginx config files. Unfortunaly this does not give any feedback
on the running terminal if reload failed or not.

Fix for #11238 should land in systemd v243 some time in the future

[0] https://github.com/systemd/systemd/issues/2175
[1] https://github.com/systemd/systemd/issues/11238
This commit is contained in:
Arti Zirk 2019-08-07 14:28:23 +03:00
parent f00c529dc3
commit b5c071a713
2 changed files with 3 additions and 3 deletions

View File

@ -14,7 +14,7 @@ _nchan_ver=1.2.6
_pkgname=nginx
pkgname=nginx-ilves
pkgver=1.17.1
pkgrel=1
pkgrel=2
pkgdesc='Lightweight HTTP server and IMAP/POP3 proxy server, mainline release'
arch=('x86_64')
url='https://nginx.org'
@ -43,7 +43,7 @@ source=("${url}/download/${_pkgname}-${pkgver}.tar.gz"{,.asc}
"ngx_nchan-${_nchan_ver}.tar.gz::https://github.com/slact/nchan/archive/v${_nchan_ver}.tar.gz")
sha256sums=('6f1825b4514e601579986035783769c456b888d3facbab78881ed9b58467e73e'
'SKIP'
'65f5af0f27ce3c5263d99d70a57fd3b0cb62aa99df786205029e68563e41e1ee'
'6985a7c271a64b9fce5fb24afc459399643a7abf5e7f1a1cc5043c4941443892'
'06ebe161af3e761f2e2e35a67c6c0af27bf61aea7cd4ba8b28372ced5e3b3175'
'd2499d94d82d4e4eac8425d799e52883131ae86a956524040ff2fd230ef9f859'
'81698fb0c1ec9f906ce308c055d5d248085caf390f4b92516c1ec93f87c886d4'

View File

@ -9,7 +9,7 @@ PrivateDevices=yes
SyslogLevel=err
ExecStart=/usr/bin/nginx -g 'pid /run/nginx.pid; error_log stderr;'
ExecReload=/usr/bin/nginx -s reload
ExecReload=-/usr/bin/sh -c '/usr/bin/nginx -t && /usr/bin/nginx -s reload'
KillSignal=SIGQUIT
KillMode=mixed