File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Python script for the Python Demo Service
2
+
3
+ if __name__ == '__main__' :
4
+ import time
5
+ import systemd .daemon
6
+
7
+ print ('Starting up ...' )
8
+ time .sleep (10 )
9
+ print ('Startup complete' )
10
+ # Tell systemd that our service is ready
11
+ systemd .daemon .notify ('READY=1' )
12
+
13
+ while True :
14
+ print ('Hello from the Python Demo Service' )
15
+ time .sleep (5 )
16
+
Original file line number Diff line number Diff line change
1
+ # systemd unit file for the Python Demo Service
2
+
3
+
4
+ [Unit]
5
+
6
+ # Human readable name of the unit
7
+ Description =Python Demo Service
8
+
9
+
10
+ [Service]
11
+
12
+ # Command to execute when the service is started
13
+ ExecStart =/usr/bin/python /usr/local/lib/python_demo_service/python_demo_service.py
14
+
15
+ # Disable Python's buffering of STDOUT and STDERR, so that output from the
16
+ # service shows up immediately in systemd's logs
17
+ Environment =PYTHONUNBUFFERED =1
18
+
19
+ # Automatically restart the service if it crashes
20
+ Restart =on-failure
21
+
22
+ # Our service will notify systemd once it is up and running
23
+ Type =notify
24
+
25
+ # Use a dedicated user to run our service
26
+ User =python_demo_service
27
+
28
+
29
+ [Install]
30
+
31
+ # Tell systemd to automatically start this service when the system boots
32
+ # (assuming the service is enabled)
33
+ WantedBy =default.target
34
+
You can’t perform that action at this time.
0 commit comments