lockex

Crates.iolockex
lib.rslockex
version0.1.1
created_at2025-10-24 09:05:30.312828+00
updated_at2025-10-24 09:16:28.314092+00
descriptionsimple command executor with locking and state
homepagehttps://codeberg.org/micropanda123/lockex
repositoryhttps://codeberg.org/micropanda123/lockex
max_upload_size
id1898181
size21,532
(MicroPanda123)

documentation

README

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 1 and shows error, skipping execution
    • if does not exist, acquires it
  • 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
  • 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
Commit count: 0

cargo fmt