pomander
pomander copied to clipboard
deploy.lock
While a deploy is running, create a deploy.lock file so that subsequent deploys cannot be happening at the same time.
Things to look out for:
If a deploy fails, will it always be able to remove the deploy.lock file? If it cannot, people will be stuck without being able to deploy.
There would need to be a "force" option to override a locked deploy.
You can look at flock. Example code
$flock = new FLock(__CLASS__);
if ($flock->isLocked()) {
$output->writeln("<error> Command ". $this->getName(). " already running in this system. Kill it or try again later </error>", OutputInterface::VERBOSITY_QUIET);
return -1;
}
which uses class Flock from https://github.com/intaro/pinboard/issues/61#issuecomment-35647379. This realization must unlock file when process failed.