[#272] Support for external stop/restart control on the application #273

Merged
blacklight merged 18 commits from 272/external-proc-controller into master 2023-08-15 21:34:44 +02:00

18 Commits

Author SHA1 Message Date
Fabio Manganiello fef6513cc8
Alpine Linux requires the linux-headers package to build psutil.
continuous-integration/drone/push Build is passing Details
2023-08-15 11:40:02 +02:00
Fabio Manganiello 00863a176e
Added `application` plugin.
continuous-integration/drone/push Build is failing Details
2023-08-15 11:20:24 +02:00
Fabio Manganiello f51beb271e
Large refactor + stability fixes for the external process control logic. 2023-08-15 11:12:21 +02:00
Fabio Manganiello 46245e851f
Synchronize with the currently running stop thread (if any) in `Backend.wait_stop`. 2023-08-15 02:08:47 +02:00
Fabio Manganiello a8a7ceb2ac
Implemented `HttpBackend._stop_workers`.
The Tornado WSGI container won't guarantee the termination of the
spawned workers upon termination, so the code of the backend has to take
care of it and terminate all the children processes of the server
process when it terminates.

This also means that `psutil` is now a required base dependency, as we
need to expand the process subtree under the webserver launcher.
2023-08-15 00:13:34 +02:00
Fabio Manganiello 04921c759f
Added `wait_stop` method to the entities engine and cron scheduler. 2023-08-14 23:49:47 +02:00
Fabio Manganiello ceb9d6d1ba
Removed redundant `Backend._get_redis()` method.
It was used only once, and it could easily be replaced by
`platypush.utils.get_redis()`.
2023-08-14 23:37:38 +02:00
Fabio Manganiello 7157936b87
Added get_remaining_timeout utility function. 2023-08-14 23:17:50 +02:00
Fabio Manganiello dc1a152433
Added `get_default_pid_file` utility method. 2023-08-14 10:47:25 +02:00
Fabio Manganiello c11bc69a66
Handle `KeyboardInterrupt` and process return code in the main. 2023-08-13 23:55:40 +02:00
Fabio Manganiello 8819a0ed4c
Added `CommandStream` to the main `Application`.
The stream will be used to communicate command messages from the
application to its runner.
2023-08-13 23:51:21 +02:00
Fabio Manganiello 06111587f7
Added `CommandStream` class.
This abstraction is used to write and read commands over a UNIX socket.
2023-08-13 23:37:51 +02:00
Fabio Manganiello c89f992867
Added `StopCommand` and `RestartCommand`. 2023-08-13 23:36:36 +02:00
Fabio Manganiello b1f244a812
Added `ControllableProcess` class.
This class can be used to easily control the execution of underlying
processes.
2023-08-13 23:33:08 +02:00
Fabio Manganiello efef9d7bc0
Added `commands` module. 2023-08-13 23:21:36 +02:00
Fabio Manganiello 97adc3f775
Moved application argument parser to an external `platypush.cli` module. 2023-08-13 22:27:16 +02:00
Fabio Manganiello 1819ee75ef
`s/Application.stop_app/Application.stop/g` 2023-08-13 22:23:15 +02:00
Fabio Manganiello 827b564006
Using a single constant for DEFAULT_REDIS_QUEUE.
Also, catch `AttributeError` on `self._proc.terminate` in the
`HttpBackend`, since the process may already have been terminated and
set to null by another worker process.
2023-08-13 22:20:16 +02:00