Rigel: Difference between revisions

From Personal wiki
(specification for regular.csv config file)
(structural changes)
Line 1: Line 1:
Server
Server that runs all applications and manages all data. It does not run the router.


==== regular.py ====
=== regular.py ===
Python script to coordinate recurring automation tasks. It reads a config file regular.csv and executes commands inside LXC containers at specified times and time intervals.
Python script to coordinate recurring automation tasks. It reads a config file regular.csv and executes commands inside LXC containers at specified times and time intervals.


===== regular.csv =====
==== regular.csv ====
 
"<code>;</code>"-delimited CSV file, header line is "<code>id;interval;start;depends;lxc_name;username;command</code>". Each subsequent line specifies a command and how and when it has to be run. <code>lxc_name</code> specifies the LXC container under which to run, <code>username</code> the user within that container and <code>command</code> the exact command, which cannot have spaces in its arguments (<code>true '1 2' 3</code> will evaluate to <code>"true" "'1" "2'" "3"</code>):<syntaxhighlight lang="shell">
"<code>;</code>"-delimited CSV file, header line is "<code>id;interval;start;depends;lxc_name;username;command</code>". Each subsequent line specifies a command and how and when it has to be run. <code>lxc_name</code> specifies the LXC container under which to run, <code>username</code> the user within that container and <code>command</code> the exact command, which cannot have spaces in its arguments (<code>true '1 2' 3</code> will evaluate to <code>"true" "'1" "2'" "3"</code>):<syntaxhighlight lang="shell">
$ sudo lxc-attach -n {lxc_name} -- sudo -u {username} -- {command.split(' ')}
$ sudo lxc-attach -n {lxc_name} -- sudo -u {username} -- {command.split(' ')}
</syntaxhighlight><code>start</code> is a 4-digit string in <code>%H%M</code> format at which time the command should be excecuted, and <code>interval</code> is a number of hours specifying how much hours after <code>start</code> the command should be run again, e.g. 24, 12 or 8 for one, two and three runs a day respectively. The <code>depends</code> column specifies whether the task is a parent task (empty <code>depends</code>) or a child task. Children tasks will be executed exactly after their parent, specified by<code>depends</code> containing the <code>id</code> of the parent, finishes execution. The parent must be in a line above the child's, and the child's <code>interval</code> and <code>start</code> values are ignored and can be empty. If multiple children depend on the same parent, they will be run in the order they are listed in the .csv file from top to bottom.
</syntaxhighlight><code>start</code> is a 4-digit string in <code>%H%M</code> format at which time the command should be excecuted, and <code>interval</code> is a number of hours specifying how much hours after <code>start</code> the command should be run again, e.g. 24, 12 or 8 for one, two and three runs a day respectively. The <code>depends</code> column specifies whether the task is a parent task (empty <code>depends</code>) or a child task. Children tasks will be executed exactly after their parent, specified by<code>depends</code> containing the <code>id</code> of the parent, finishes execution. The parent must be in a line above the child's, and the child's <code>interval</code> and <code>start</code> values are ignored and can be empty. If multiple children depend on the same parent, they will be run in the order they are listed in the .csv file from top to bottom.

Revision as of 10:35, 8 April 2022

Server that runs all applications and manages all data. It does not run the router.

regular.py

Python script to coordinate recurring automation tasks. It reads a config file regular.csv and executes commands inside LXC containers at specified times and time intervals.

regular.csv

";"-delimited CSV file, header line is "id;interval;start;depends;lxc_name;username;command". Each subsequent line specifies a command and how and when it has to be run. lxc_name specifies the LXC container under which to run, username the user within that container and command the exact command, which cannot have spaces in its arguments (true '1 2' 3 will evaluate to "true" "'1" "2'" "3"):

$ sudo lxc-attach -n {lxc_name} -- sudo -u {username} -- {command.split(' ')}

start is a 4-digit string in %H%M format at which time the command should be excecuted, and interval is a number of hours specifying how much hours after start the command should be run again, e.g. 24, 12 or 8 for one, two and three runs a day respectively. The depends column specifies whether the task is a parent task (empty depends) or a child task. Children tasks will be executed exactly after their parent, specified bydepends containing the id of the parent, finishes execution. The parent must be in a line above the child's, and the child's interval and start values are ignored and can be empty. If multiple children depend on the same parent, they will be run in the order they are listed in the .csv file from top to bottom.