diff --git a/.gitignore b/.gitignore index deea6b4..800064d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /dist/ /glloq *.lock +*.glloq # Created by https://www.toptal.com/developers/gitignore/api/go # Edit at https://www.toptal.com/developers/gitignore?templates=go diff --git a/README.md b/README.md index 450da00..db06801 100644 --- a/README.md +++ b/README.md @@ -22,16 +22,20 @@ but you can very easily implement your own. ### As a CLI ```bash -# Supported DSNs include PostgreSQL (CockroachDB, ...), MySQL (Maria, ...), Files. -export GLLOQ_DSN=postgres://user:password@postgres:5432/mydb?sslmode=disable +# By default, glloq will use a ".glloq" lock file in the current working directory. +glloq sleep 10 & +glloq echo ok # This displays "ok" in 10 seconds + +# Supported backends include PostgreSQL (CockroachDB, ...), MySQL (Maria, ...) and local files. +export GLLOQ_DSN="postgres://user:password@postgres:5432/mydb?sslmode=disable" # This wont run concurrently -glloq run_migrations.sh +glloq run_db_migrations.sh -# Override default timeout of 60 seconds to 10 minutes. +# You can override default timeout of 1 minute to 10 minutes. export GLLOQ_TIMEOUT=600 -# You can specify a lock ID (if the back-end supports it) +# You can specify a lock key (if supported by the backend). GLLOQ_KEY=concurrent0 glloq run_migrations_0.sh GLLOQ_KEY=concurrent1 glloq run_migrations_1.sh ``` diff --git a/cmd/main.go b/cmd/main.go index 313642a..7770b5f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "os/exec" - "path" "strconv" "strings" "time" @@ -39,9 +38,7 @@ func RunGlloq(env []string, args []string) (int, error) { dsn := opts["dsn"] if dsn == "" { - // No DSN set, just use a static file. - tmpdir := os.TempDir() - dsn = "file://" + path.Join(tmpdir, "glloq-edw3KBE") + dsn = "file://.glloq" } timeoutSeconds, _ := strconv.Atoi(opts["timeout"]) lockerOptions := glloq.Options{