changedetection.io icon indicating copy to clipboard operation
changedetection.io copied to clipboard

[feature] Support SIGTERM for cleaner/faster shutdowns

Open dgtlmoon opened this issue 2 years ago • 5 comments

We should support SIGTERM for cleaner/faster shutdowns, this can also help in the case where people shut down and the JSON DB is not saved

https://vsupalov.com/docker-compose-stop-slow

definitely want to test that the windows implementation is not broken when implementing any signal handling

dgtlmoon avatar Jun 15 '22 09:06 dgtlmoon

https://github.com/dgtlmoon/changedetection.io/pull/737

dgtlmoon avatar Jul 04 '22 20:07 dgtlmoon

Hi, I noticed with this change wsgi is receiving a SIGCHLD for some reason so the http server doesn't stay up.

changedetection      | Shutdown: Got SIGCHLD
changedetection      | (8) wsgi exited, is_accepting=True
changedetection      | Process Process-1:
changedetection      | Traceback (most recent call last):
changedetection      |   File "/usr/local/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
changedetection      |     self.run()
changedetection      |   File "/usr/local/lib/python3.8/multiprocessing/process.py", line 108, in run
changedetection      |     self._target(*self._args, **self._kwargs)
changedetection      |   File "/app/changedetectionio/changedetection.py", line 130, in main
changedetection      |     eventlet.wsgi.server(eventlet.listen((host, int(port))), app)
changedetection      |   File "/usr/local/eventlet/wsgi.py", line 1002, in server
changedetection      |     client_socket, client_addr = sock.accept()
changedetection      |   File "/usr/local/eventlet/greenio/base.py", line 233, in accept
changedetection      |     self._trampoline(fd, read=True, timeout=self.gettimeout(), timeout_exc=_timeout_exc)
changedetection      |   File "/usr/local/eventlet/greenio/base.py", line 211, in _trampoline
changedetection      |     return trampoline(fd, read=read, write=write, timeout=timeout,
changedetection      |   File "/usr/local/eventlet/hubs/__init__.py", line 159, in trampoline
changedetection      |     return hub.switch()
changedetection      |   File "/usr/local/eventlet/hubs/hub.py", line 313, in switch
changedetection      |     return self.greenlet.switch()
changedetection      |   File "/usr/local/eventlet/hubs/hub.py", line 365, in run
changedetection      |     self.wait(sleep_time)
changedetection      |   File "/usr/local/eventlet/hubs/poll.py", line 80, in wait
changedetection      |     presult = self.do_poll(seconds)
changedetection      |   File "/usr/local/eventlet/hubs/epolls.py", line 31, in do_poll
changedetection      |     return self.poll.poll(seconds)
changedetection      |   File "./changedetection.py", line 17, in sigterm_handler
changedetection      |     pid, status = os.waitpid(-1, os.WNOHANG | os.WUNTRACED | os.WCONTINUED)
changedetection      | ChildProcessError: [Errno 10] No child processes

stephenjamieson avatar Aug 04 '22 21:08 stephenjamieson

@stephenjamieson you must be on the docker :dev right ? can you retest with https://github.com/dgtlmoon/changedetection.io/actions/runs/2799910171 when its complete?

and next time - please tell me

version and docker tag

otherwise your comment could get deleted/ignored

dgtlmoon avatar Aug 04 '22 22:08 dgtlmoon

Yes, will do.

stephenjamieson avatar Aug 04 '22 22:08 stephenjamieson

👍 Looks good in the latest dev.

stephenjamieson avatar Aug 04 '22 23:08 stephenjamieson