mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-20 20:16:26 +02:00
Improve containers stopping performance by handling SIGTERM
This commit is contained in:
parent
b9adb6f854
commit
fef00b96f1
4 changed files with 32 additions and 6 deletions
18
repo/serve.py
Normal file
18
repo/serve.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import signal
|
||||
import sys
|
||||
import http.server
|
||||
import socketserver
|
||||
|
||||
PORT = 8000
|
||||
|
||||
Handler = http.server.SimpleHTTPRequestHandler
|
||||
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
||||
print("serving at port", PORT)
|
||||
httpd.serve_forever()
|
Loading…
Add table
Add a link
Reference in a new issue