Long lived Python/PHP daemon-script-wrapper with Supervisor instead Cron schedules
All novice Linux users and seasoned sysadmins know that Cron is a great simple solution to the problem of regularly calling the same application, it is present in almost every Linux system, has simple syntax and a number of logging and warning functions that make it a great addition to system administrator tools.
However, the Cron solution has some limitations.
- The minimum time is limited to 1 minute – this is the shortest repeating interval that you can configure.
- Minimal support to avoid concurrency.
- It almost completely ignores the state of the command being called, that is, if the script fails, Cron will just keep trying (as it should), and you, as an administrator, should check and diagnose the problem.
- But what if you need to implement a robust “long-lived” application in Python or PHP?
Not everything can fit into convenient 1-minute time intervals for program code execution. In addition, there is an unnecessary overhead for loading the required libraries and opening file and socket descriptors each time the program is called for execution.
What if your application code needs to maintain a connection to a remote server and respond to events on an ad-hoc basis? Probably someone will say that these are already full-fledged demon programs. But the line between a daemon and a long-lived application in scripting languages is not very clear.
“Long lived Python/PHP daemon-script-wrapper with Supervisor instead Cron schedules”Continue reading
Protected: Openstack: daemon for collecting statistics of billing SWIFT storage based on supervisord with threads.
Openstack CLI: Unset all variables beginning with prefix OS_
When using the Openstack CLI, you typically will get a shell script that you would source, which will export a bunch of variables to your session. I have run into the problem of switching between two different Openstack installs that were on different versions, and needed different variables. Also you will be need this when you will be generate parameters in different areas of scope for last version of keystone. Accordingly, the following example will unset all Openstack variables (all variables that begin with OS_)
Need create file reset_OS.sh with next content:
1 2 3 | #!/bin/bash # ${!varprefix@} Matches all previously declared variables beginning with varprefix unset ${!OS_@} |
and use in next manner:
1 | $ . ./reset_OS.sh |