2019-01-23 15:13:29 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2021-08-27 16:45:16 +02:00
|
|
|
import logging
|
|
|
|
|
2019-01-23 15:13:29 +01:00
|
|
|
from subprocess import Popen
|
2021-08-27 16:45:16 +02:00
|
|
|
|
|
|
|
from lookyloo.abstractmanager import AbstractManager
|
|
|
|
from lookyloo.helpers import get_homedir, get_config, set_running
|
|
|
|
|
|
|
|
logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s:%(message)s',
|
|
|
|
level=logging.INFO, datefmt='%I:%M:%S')
|
|
|
|
|
|
|
|
|
|
|
|
class Website(AbstractManager):
|
|
|
|
|
|
|
|
def __init__(self, loglevel: int=logging.INFO):
|
|
|
|
super().__init__(loglevel)
|
|
|
|
self.script_name = 'website'
|
|
|
|
self.process = self._launch_website()
|
|
|
|
set_running(self.script_name)
|
|
|
|
|
|
|
|
def _launch_website(self):
|
|
|
|
website_dir = get_homedir() / 'website'
|
|
|
|
ip = get_config('generic', 'website_listen_ip')
|
|
|
|
port = get_config('generic', 'website_listen_port')
|
|
|
|
return Popen(['gunicorn', '-w', '10',
|
|
|
|
'--graceful-timeout', '2', '--timeout', '300',
|
|
|
|
'-b', f'{ip}:{port}',
|
|
|
|
'--log-level', 'info',
|
|
|
|
'web:app'],
|
|
|
|
cwd=website_dir)
|
2019-04-05 15:07:22 +02:00
|
|
|
|
2019-01-23 15:13:29 +01:00
|
|
|
|
2020-10-03 21:19:43 +02:00
|
|
|
def main():
|
2021-08-27 16:45:16 +02:00
|
|
|
w = Website()
|
|
|
|
w.run(sleep_in_sec=10)
|
2020-10-03 21:19:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|