Skip to content

Commit 4d040f9

Browse files
committed
added systemctl service
1 parent 00d9837 commit 4d040f9

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

pythonms

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/python
2+
3+
#local imports
4+
from modules.worker import Worker
5+
from modules.server import Server
6+
from modules.commands import quit
7+
#external imports
8+
from importlib import import_module
9+
from sys import stdout
10+
import logging as log
11+
import config
12+
13+
LOG_FILENAME = 'python_manager.log'
14+
worker = Worker()
15+
server = None
16+
17+
def __init__():
18+
global server
19+
# log.basicConfig(filename=LOG_FILENAME,level=log.DEBUG)
20+
log.basicConfig(level=log.DEBUG)
21+
server = Server(config.daemon, worker)
22+
worker.init(server)
23+
24+
def main():
25+
__init__()
26+
worker.start()
27+
server.start()
28+
log.info('All tasks done. Stopping')
29+
return 0
30+
31+
if __name__ == '__main__':
32+
try:
33+
main()
34+
except KeyboardInterrupt as e:
35+
quit(worker, [], server)

pythonms.service

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Python subservices manager
3+
Documentation=
4+
5+
[Service]
6+
ExecStart=/usr/bin/pythonms > /var/log/pythonms.log
7+
Restart=on-failure
8+
SuccessExitStatus=3 4
9+
RestartForceExitStatus=3 4
10+
11+
[Install]
12+
WantedBy=default.target

0 commit comments

Comments
 (0)