Beam::Runnable::Single - Only allow one instance of this command at a time
version 0.016
### In a Runnable module package My::Runnable::Script; use Moo; with 'Beam::Runnable', 'Beam::Runnable::Single'; has '+pid_file' => ( default => '/var/run/runnable-script.pid' ); sub run { } ### In a container config file runnable: $class: My::Runnable::Script $with: - 'Beam::Runnable::Single' pid_file: /var/run/runnable-script.pid
This role checks to ensure that only one instance of the command is running at a time. If another instance tries to run, it dies with an error instead.
Users should have access to read/write the path pointed to by "pid_file", and to read/write the directory containing the PID file.
If the command exits prematurely, the PID file will not be cleaned up. If this is undesirable, make sure to trap exceptions in your run() method and return the exit code you want.
run()
The path to a file containing the PID of the currently-running script.
This role wraps the run method of your runnable class to check that there is no running instance of this task (the PID file does not exist).
run
Beam::Runnable
Doug Bell <preaction@cpan.org>
This software is copyright (c) 2016 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Beam::Runner, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Beam::Runner
CPAN shell
perl -MCPAN -e shell install Beam::Runner
For more information on module installation, please visit the detailed CPAN module installation guide.