<commit_before># sera

Distributed Mutex locking using a mysql database

## Introduction

`sera` can stop commands from running at the same time in clustered environment.
  
For example you might have two servers running two task at the same time and this can cause
race conditions. This is normally prevented via a Message Queue (MQ) system, but there are
cases where using a MQ is over

`sera` relies on the MySQL `get_lock()` function to ensure that only one instance in a cluster
is running a command at any time. `get_lock()` is typically not supported in a master-master or 
master-slave environment.

## Usage

	sera <wait-time-in-seconds> <command to run> < .. arguments and flags to command>


### wait-time-in-seconds

This is how many seconds sera will wait for a lock to be released until it gives up and aborts
running the command. This number can be 0. 

<<<<<<< HEAD
=======
sera takes two arguments, the first one is how the is how long in seconds it would take to complete the task (upper bound). After this time another instance of sera will be able to run this job.
>>>>>>> 53a5e4b87bde87e2670efc6bf8b280da643b3d37

### command to run and flags

The second and subsequent arguments is what command sera will execute. It will use the name of 
the commands and arguments as the name for which the lock.
 
## Example

![Sera example](sera.png)


## Configuration

`/etc/sera.json`

	{
            "server": "sera:secret@tcp(127.0.0.1:3306)/?timeout=500ms",
            "syslog": true,
            "verbose": true
    }
    
**server**:  A Data Source Name string for connecting to a MySQL database, as described 
here (https://github.com/go-sql-driver/mysql#dsn-data-source-name)[https://github.com/go-sql-driver/mysql#dsn-data-source-name]

**syslog**: If sera should log errors and failed locking attempts to syslog

**verbose**: if sera should print errors to stdout


## Installation:

Add the configuration file and either:

 - Download a binary from the (releases)[https://github.com/stojg/sera/releases]
 - Install via `go get github.com/stojg/sera && go install github.com/stojg/sera`<commit_msg>Fix broken README<commit_after># sera

Distributed Mutex locking using a mysql database

## Introduction

`sera` can stop commands from running at the same time in clustered environment.
  
For example you might have two servers running two task at the same time and this can cause
race conditions. This is normally prevented via a Message Queue (MQ) system, but there are
cases where using a MQ is over

`sera` relies on the MySQL `get_lock()` function to ensure that only one instance in a cluster
is running a command at any time. `get_lock()` is typically not supported in a master-master or 
master-slave environment.

## Usage

	sera <wait-time-in-seconds> <command to run> < .. arguments and flags to command>


### wait-time-in-seconds

This is how many seconds sera will wait for a lock to be released until it gives up and aborts
running the command. This number can be 0. 

### command to run and flags

The second and subsequent arguments is what command sera will execute. It will use the name of 
the commands and arguments as the name for which the lock.
 
## Example

![Sera example](https://raw.githubusercontent.com/stojg/sera/master/usage.png)


## Configuration

`/etc/sera.json`

	{
            "server": "sera:secret@tcp(127.0.0.1:3306)/?timeout=500ms",
            "syslog": true,
            "verbose": true
    }
    
**server**:  A Data Source Name string for connecting to a MySQL database, as described 
here (https://github.com/go-sql-driver/mysql#dsn-data-source-name)[https://github.com/go-sql-driver/mysql#dsn-data-source-name]

**syslog**: If sera should log errors and failed locking attempts to syslog

**verbose**: if sera should print errors to stdout


## Installation:

Add the configuration file and either:

 - Download a binary from the (releases)[https://github.com/stojg/sera/releases]
 - Install via `go get github.com/stojg/sera && go install github.com/stojg/sera`
{'fraction_non_alphanumeric': 0.09054825105432895, 'fraction_numerical': 0.012651947407591168, 'mean_word_length': 3.794292508917955, 'pattern_counts': {'":': 6, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1385754', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1145, 'n_words': 517}