[IMP] server: intercept SIGXCPU and shutdown gracefully
When the runbot spawns an Odoo instance, a CPU TIME limit is set. When this limit is reached, the kernel kills the Odoo instance and no message appears in the logs leaving the dev in a deep smoke cloud. With this commit, the signal sent by the kernel when the soft limit is reached (SIGXCPU), is intercepeted and Odoo shutdown gracefully with a nice message for the dev.
This commit is contained in:
@@ -207,6 +207,9 @@ class ThreadedServer(CommonServer):
|
||||
os._exit(0)
|
||||
# interrupt run() to start shutdown
|
||||
raise KeyboardInterrupt()
|
||||
elif sig == signal.SIGXCPU:
|
||||
sys.stderr.write("CPU time limit exceeded! Shutting down immediately\n")
|
||||
os._exit(0)
|
||||
elif sig == signal.SIGHUP:
|
||||
# restart on kill -HUP
|
||||
odoo.phoenix = True
|
||||
@@ -266,6 +269,7 @@ class ThreadedServer(CommonServer):
|
||||
signal.signal(signal.SIGTERM, self.signal_handler)
|
||||
signal.signal(signal.SIGCHLD, self.signal_handler)
|
||||
signal.signal(signal.SIGHUP, self.signal_handler)
|
||||
signal.signal(signal.SIGXCPU, self.signal_handler)
|
||||
signal.signal(signal.SIGQUIT, dumpstacks)
|
||||
signal.signal(signal.SIGUSR1, log_ormcache_stats)
|
||||
elif os.name == 'nt':
|
||||
@@ -373,7 +377,7 @@ class GeventServer(CommonServer):
|
||||
signal.signal(signal.SIGQUIT, dumpstacks)
|
||||
signal.signal(signal.SIGUSR1, log_ormcache_stats)
|
||||
gevent.spawn(self.watchdog)
|
||||
|
||||
|
||||
self.httpd = WSGIServer((self.interface, self.port), self.app)
|
||||
_logger.info('Evented Service (longpolling) running on %s:%s', self.interface, self.port)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user