Skip to content

Commit

Permalink
Merge pull request #152 from mrf345/testing
Browse files Browse the repository at this point in the history
Fix cli gevent exit, Resolves #151
  • Loading branch information
mrf345 authored Jun 19, 2020
2 parents fcda49a + a3d470a commit 7902647
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import sys
import click
from importlib import import_module
import gevent
import signal
from gevent import monkey, pywsgi
from importlib import import_module

from app.main import bundle_app
from app.utils import get_accessible_ips, get_random_available_port, log_error
Expand Down Expand Up @@ -36,7 +38,12 @@ def start_cli():
monkey.patch_socket()

try:
pywsgi.WSGIServer((str(alt_ip), int(alt_port)), app, log=None if quiet else 'default').serve_forever()
server = pywsgi.WSGIServer((str(alt_ip), int(alt_port)),
app,
log=None if quiet else 'default')
gevent.signal(signal.SIGTERM, server.stop)
server.serve_forever()
gevent.get_hub().join()
except KeyboardInterrupt:
stop_tasks()

Expand Down

0 comments on commit 7902647

Please sign in to comment.