exec
Version, currently 1.0.01 version
- 1.0.0latestJan 22, 2022
github.com/mgomes/exec
Periodically execute Crystal code blocks
Installation
# Add this to your shard.yml
dependencies:
exec:
github: mgomes/exec
version: ~> 1.0.0Then run:
shards installshard.yml
- Crystal
~> 1.0- License
- MIT
- Author
- Mauricio Gomes
Dependencies
This version declares no dependencies.
README
Exec
A lightweight library for executing blocks at specified intervals. This library aims to solve the following:
- Reliably run blocks at specified intervals regardless of the runtime duration of the block.
- Keep it light (avoid timezones and dependencies)
Installation
-
Add the dependency to your
shard.yml:dependencies: exec: github: mgomes/exec -
Run
shards install
Usage
require "exec"
Specify the execution intervals for your code blocks:
Exec.every(1.second) do
do_work
end
Exec.every(3.hours) do
do_work
end
Caveats
-
In the usage examples above, if the
do_workmethod takes longer to execute than the specified interval, the next interval will be executed before the existing code block has completed. Therefore, multiple versions ofdo_workwill be executing concurrently. If this is a concern for your code block, ensure you have enough margin built into the interval or that you've built in other safety measures to prevent corruption. -
You'll likely want to compile your applications with the
-Dpreview_mtflag to take advantage of parallel execution. You can then run your binary with theCRYSTAL_WORKERS=Nenvironment variable. SetNto the number of cores on your CPU.
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.0.0- Tagged
- Jan 22, 2022
- Commit
1e2bdb3e746e- Crystal
~> 1.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/mgomes/exec
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 17, 2026
- Synced
- Aug 17, 2026
- Versions
- 1