PHPackages                             ingenerator/runsingle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ingenerator/runsingle

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

ingenerator/runsingle
=====================

Wrapper package for ensuring a script is only run once across multiple instances.

v1.0.0(7y ago)09.6kBSD-3-ClausePHPPHP ^7.2

Since Apr 3Pushed 4y ago2 watchersCompare

[ Source](https://github.com/ingenerator/runsingle)[ Packagist](https://packagist.org/packages/ingenerator/runsingle)[ Docs](https://github.com/ingenerator/runsingle)[ RSS](/packages/ingenerator-runsingle/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

ABANDONED PACKAGE
=================

[](#abandoned-package)

**This package was abandoned on 9th March 2022 and will no longer be maintained. It was working and in use up to that date. It may be viable to fork, if still required, equally there are now various well-supported options for more generic locking packages (e.g. symfony/lock) which may be suitable if the tasks you want to run are PHP processes.**

RunSingle
=========

[](#runsingle)

[![License](https://camo.githubusercontent.com/e67c7cbf23cf7ada156ee21dffbca771e4be73198221427f4c67e4cf4fdaa0c3/68747470733a2f2f706f7365722e707567782e6f72672f696e67656e657261746f722f72756e73696e676c652f6c6963656e73652e737667)](https://packagist.org/packages/ingenerator/runsingle)[![Master Build Status](https://camo.githubusercontent.com/5ab021b3e1cb908c016366b5c76c7b40a621d05ba3c5d778a3ed06e30e695c09/68747470733a2f2f7472617669732d63692e6f72672f696e67656e657261746f722f72756e73696e676c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/ingenerator/runsingle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0c479e1b846b73e9a934f7c803d293e743e583da68ea3e0da3848b1e3c896ea2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696e67656e657261746f722f72756e73696e676c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ingenerator/runsingle/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/8da0f8a7b261ef61ec9cab19cbc18d1663ad50c794601e89e1f31775e29181a5/68747470733a2f2f706f7365722e707567782e6f72672f696e67656e657261746f722f72756e73696e676c652f762f737461626c652e737667)](https://packagist.org/packages/ingenerator/runsingle)[![Total Downloads](https://camo.githubusercontent.com/3a7a077c627222f41c94347b9d3bb286617629409c2a349adb7a9a2cc08f6a54/68747470733a2f2f706f7365722e707567782e6f72672f696e67656e657261746f722f72756e73696e676c652f646f776e6c6f6164732e737667)](https://packagist.org/packages/ingenerator/runsingle)[![Latest Unstable Version](https://camo.githubusercontent.com/bfa43ee848f90f9e9000c125feda140cf3122cf8c171b79437036a73bf761344/68747470733a2f2f706f7365722e707567782e6f72672f696e67656e657261746f722f72756e73696e676c652f762f756e737461626c652e737667)](https://packagist.org/packages/ingenerator/runsingle)

... is a locking wrapper to ensure a command is only being run once at any given time across multiple instances. Locking is done via a database on a remote host.

Installing and building your database
-------------------------------------

[](#installing-and-building-your-database)

Clone or download this repository, or just add it to your composer.json:

```
{
  "require": {
    "ingenerator/RunSingle" : "0.*"
  }
}
```

You will need php.

Initial DB configuration
------------------------

[](#initial-db-configuration)

For use with the standard driver, RunSingle needs access to a MySql database with a table containing these fields:

```
CREATE TABLE IF NOT EXISTS locks (
  task_name varchar(255),
  lock_timestamp int,
  timeout int,
  lock_holder varchar(255),
  PRIMARY KEY (task_name)
  );
```

Create a file named 'run\_single\_config.php' in your project root on each instance. This file should return a LockDriver. You can return the standard database driver by passing the credentials to the DbDriverFactory, e.g.:

```
