def main(): r = StrictRedis(unix_socket_path=get_socket_path('cache')) r.delete('cache_loaded') website_dir = get_homedir() / 'website' ip = get_config('generic', 'website_listen_ip') port = get_config('generic', 'website_listen_port') try: p = Popen([ 'gunicorn', '-w', '10', '--graceful-timeout', '2', '--timeout', '300', '-b', f'{ip}:{port}', '--log-level', 'info', 'web:app' ], cwd=website_dir) set_running('website') while True: if shutdown_requested() or p.poll() is not None: break time.sleep(1) except KeyboardInterrupt: print('Website killed by user.') finally: print('Shutting down website.') try: # Killing everything if possible. p.send_signal(signal.SIGWINCH) p.send_signal(signal.SIGTERM) except Exception: pass unset_running('website')
def _to_run_forever(self): set_running('async_scrape') while True: url = self.lookyloo.process_scrape_queue() if url is None or shutdown_requested(): break unset_running('async_scrape')
from redis import StrictRedis if __name__ == '__main__': r = StrictRedis(unix_socket_path=get_socket_path('cache')) r.delete('cache_loaded') website_dir = get_homedir() / 'website' Popen([str(website_dir / '3rdparty.sh')], cwd=website_dir) try: p = Popen(['gunicorn', '--worker-class', 'eventlet', '-w', '10', '--graceful-timeout', '2', '--timeout', '30', '-b', '0.0.0.0:5100', 'web:app'], cwd=website_dir) set_running('website') while True: if shutdown_requested() or p.poll() is not None: break time.sleep(1) except KeyboardInterrupt: print('Website killed by user.') finally: print('Shutting down website.') try: # Killing everything if possible. p.send_signal(signal.SIGWINCH) p.send_signal(signal.SIGTERM) except Exception: pass unset_running('website')