Skip to content

Commit

Permalink
stop gracefully venvs. Solves #3
Browse files Browse the repository at this point in the history
  • Loading branch information
juan cañete committed Oct 14, 2017
1 parent 4e7f23a commit 793c32b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/komlogd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import asyncio
import argparse
import functools
import subprocess
import traceback
from stat import S_ISFIFO, S_ISREG
from komlogd.api.model import transactions
Expand Down Expand Up @@ -80,6 +81,15 @@ async def start(self):

async def stop(self):
logging.logger.debug('Stopping komlogd.')
for env in self.venvs:
env['proc'].send_signal(signal.SIGTERM)
for env in self.venvs:
try:
env['proc'].wait(10)
except subprocess.TimeoutExpired:
logging.logger.error('Timeout expired waiting for virtualenv process exit: '+env['name'])
logging.logger.error('Terminating virtualenv process: '+env['name'])
env['proc'].kill()
await self.session.close()

app = None
Expand Down

0 comments on commit 793c32b

Please sign in to comment.