Skip to content

Commit 56f3db0

Browse files
committed
add sdnotify support to cli, for Systemd
fixes #1318 systemd recommends against Type=forking, preferring TYPE=notify. To do that, we need to make little api calls during startup and shutdown. Added those. This makes systemd happier on startup and seems to show status messages correctly.
1 parent a4af0e2 commit 56f3db0

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

debian/metpx-sr3.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ After=network-online.target local-fs.target remote-fs.target
1111
Requires=network-online.target
1212

1313
[Service]
14-
Type=forking
14+
Type=Notify
1515
ExecStart=/usr/bin/sr3 start
1616
User=sarra
1717
Group=sarra

sarracenia/featuredetection.py

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
's3' : { 'modules_needed': [ 'boto3' ], 'present': False,
9292
'lament' : 'cannot connect natively to S3-compatible locations (AWS S3, Minio, etc..)',
9393
'rejoice': 'able to connect natively to S3-compatible locations (AWS S3, Minio, etc..)', },
94+
'sdnotify' : { 'modules_needed': [ 'sdnotify' ],
95+
'lament': 'cannot inform system of correct startup.',
96+
'rejoice': 'can tell system when correctly started.'
97+
},
9498
'sftp' : { 'modules_needed': [ 'paramiko' ],
9599
'lament': 'cannot use or access sftp/ssh based services',
96100
'rejoice': 'can use sftp or ssh based services'

sarracenia/sr.py

+13
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,13 @@ def start(self):
22762276

22772277
print('( %d ) Done' % pcount)
22782278

2279+
if sarracenia.features['sdnotify']['present']:
2280+
import sdnotify
2281+
2282+
n = sdnotify.SystemdNotifier()
2283+
n.notify("READY=1")
2284+
2285+
22792286
def run(self):
22802287
"""
22812288
docker compatible run in foreground.
@@ -2307,6 +2314,12 @@ def stop(self):
23072314

23082315
self._clean_missing_proc_state()
23092316

2317+
if sarracenia.features['sdnotify']['present']:
2318+
import sdnotify
2319+
2320+
n = sdnotify.SystemdNotifier()
2321+
n.notify("STOPPING=1")
2322+
23102323
if len(self.procs) == 0:
23112324
print('no procs running...already stopped')
23122325
return

0 commit comments

Comments
 (0)