aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2016-04-21 23:21:11 +0200
committerVG <vg@devys.org>2016-04-21 23:21:11 +0200
commit3947ef7790eba735b6d56a6f0a88b1dff39e89dd (patch)
treee6e9bd91facf17ade58fb4a9fbf5c943a2ac2e20
parent95573b5e90d88574e9110399df02865305b99f7c (diff)
downloadteaqueue-3947ef7790eba735b6d56a6f0a88b1dff39e89dd.tar.gz
teaqueue-3947ef7790eba735b6d56a6f0a88b1dff39e89dd.tar.bz2
teaqueue-3947ef7790eba735b6d56a6f0a88b1dff39e89dd.zip
Auto-commit on 807fe7afb37fe2cfcf15c9457d04f64fa11b7511
-rw-r--r--readme.rst3
-rwxr-xr-xtest.sh22
2 files changed, 24 insertions, 1 deletions
diff --git a/readme.rst b/readme.rst
index 3db9dd7..9d2ebaa 100644
--- a/readme.rst
+++ b/readme.rst
@@ -72,7 +72,8 @@ able to be interruptible without interrupting the underlying job.
.. code:: shell
#!/bin/sh
- flock -x /var/lock/transcode_my_file.sh.lock ffmpeg -i "$1" -arg -arg &
+ [ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -e "$0" "$@"
+ ffmpeg -i "$1" -arg -arg &
The first `ffmpeg` command will go to background then, the second will wait
until the first `ffmpeg` finishes. If the `teaqueue` command is interrupted,
diff --git a/test.sh b/test.sh
new file mode 100755
index 0000000..8d9fe76
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -oe "$0" "$0" "$@"
+
+LOCKDIR=/var/run/user/$UID/transcode_my_files
+
+mkdir -p "${LOCKDIR}"
+
+filename="${1}"
+maxjobs=3
+sleeptime=2
+while true; do
+ for i in $(seq $maxjobs); do
+ lockfile="${LOCKDIR}/job_${i}"
+ if ! test -e "${lockfile}"; then
+ touch "${lockfile}" || exit 1
+ sh -c "sleep 10; echo done:${filename}; rm '$lockfile'" &
+ #flock -u "$0"
+ exit 0
+ fi
+ done
+ sleep $sleeptime
+done