2 releases
Uses new Rust 2024
| 0.1.1 | Oct 24, 2025 |
|---|---|
| 0.1.0 | Oct 24, 2025 |
#198 in Configuration
10KB
201 lines
Lockex
Simple utility to help with running long-running processes cyclically.
Usage
By default lockex will read lockex.toml file inside current directory. (v0.1.1 update: now you can specify custom config file)
Format:
# Optional path to created lock path, by default '.lockex_lock'
lock_path = "something.lock"
# Optional path to created state path, by default '.lockex_state'
state = "something.state"
# Each executed command is a separate [[commands]] block
[[commands]]
# Required name of ran service
name = "cmd_name"
# Required command that's executed
command = "my_program --parameters"
# Optional time in seconds, when specified,
# lockex will keep last execution time of a command in state file
# and check if given interval passed between executions,
# will skip if less time passed
min_interval = 3600
lockex has 2 commands: run and dry-run, both will:
- check if lock file exists
- if exists, returns
1and shows error, skipping execution - if does not exist, acquires it
- if exists, returns
- for each command in config file it will:
- check if it should be ran based on the state file and
min_interval:- if previous execution happened in shorter amount of time than min_interval, it will skip this command and show message
- otherwise, it will print the command and either execute it or skip, if in
dry-run
- check if it should be ran based on the state file and
- lastly, it will save the execution time of each command in state file, and then release the lock file
Todo:
- Maybe asynchronous execution of each command? As currently it runs each command one-by-one
- Idk depends what I will need
Dependencies
~1.5–2.3MB
~45K SLoC