Remove wrapper
- Removed wrapper.py - Removed main.py - modified radical-api.service to launch the gunicorn process directly. - Removed exit code in update method.
This commit is contained in:
parent
e6f4eb5404
commit
16b3d03841
4 changed files with 2 additions and 40 deletions
|
@ -1,29 +0,0 @@
|
||||||
"""Wrapper Class to handle reboots"""
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
class Wrapper:
|
|
||||||
def __init__(self, args, stdout):
|
|
||||||
"""
|
|
||||||
Wraps another program and helps with restarting should the program request.
|
|
||||||
:param args: Arguments used to run program
|
|
||||||
:param stdout: The stdout stream to send output to
|
|
||||||
"""
|
|
||||||
self._args = args
|
|
||||||
self.process = None
|
|
||||||
self._stdout = stdout
|
|
||||||
|
|
||||||
def start(self):
|
|
||||||
"""
|
|
||||||
Start the wrapper.
|
|
||||||
:return: None
|
|
||||||
"""
|
|
||||||
self.process = subprocess.Popen(self._args, stdout=self._stdout)
|
|
||||||
while True:
|
|
||||||
while self.process.poll() is None:
|
|
||||||
pass
|
|
||||||
if self.process.returncode == 26:
|
|
||||||
self.process = subprocess.Popen(self._args, stdout=self._stdout)
|
|
||||||
else:
|
|
||||||
sys.exit()
|
|
9
main.py
9
main.py
|
@ -1,9 +0,0 @@
|
||||||
import sys
|
|
||||||
|
|
||||||
from core.wrapper import Wrapper
|
|
||||||
|
|
||||||
api = Wrapper(['python3.9', '-m', 'gunicorn', "-k", "uvicorn.workers.UvicornWorker",
|
|
||||||
"--log-config", "log.conf",
|
|
||||||
'--bind', '0.0.0.0:8000',
|
|
||||||
'api:api'], sys.stdout)
|
|
||||||
api.start()
|
|
|
@ -9,7 +9,7 @@ User=radical-api
|
||||||
Group=radical-api
|
Group=radical-api
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=20 3
|
RestartSec=20 3
|
||||||
ExecStart=/usr/bin/env python3.9 /otp/radical-api/main.py
|
ExecStart=/usr/bin/env python3.9 -m gunicorn -k uvicorn.workers.UvicornWorker --log-config log.conf --bind 0.0.0.0:8000 api:api
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi.user.target
|
WantedBy=multi.user.target
|
||||||
|
|
|
@ -12,4 +12,4 @@ router = APIRouter()
|
||||||
@router.post("/system/update")
|
@router.post("/system/update")
|
||||||
def update(access_token: APIKey = Depends(get_system_key)):
|
def update(access_token: APIKey = Depends(get_system_key)):
|
||||||
output = subprocess.check_output(['git', 'pull'], encoding='utf-8')
|
output = subprocess.check_output(['git', 'pull'], encoding='utf-8')
|
||||||
sys.exit(26) # exit with restart code
|
sys.exit()
|
||||||
|
|
Loading…
Reference in a new issue