summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2015-11-04 09:18:05 +0100
committerThibault Saunier <tsaunier@gnome.org>2015-11-04 09:56:20 +0100
commitcca6f3f6a373f726103e71c628ecea82715a0ec4 (patch)
tree0e38fc6efad20002f43389700a669c1804bc1fec
parent1e9c0bcc7aa9a1b1e52eeb8a600f67a268ec09d0 (diff)
linux_bundle: Use a lock file to avoid several instance of a bundle to be launched
To avoid rescanning the registry at each start we symlink the plugins to some user directory and thus we can not have several bundle launched at once
-rw-r--r--cerbero/packages/linux_bundle.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/cerbero/packages/linux_bundle.py b/cerbero/packages/linux_bundle.py
index 7623d5c2..7b6c38d9 100644
--- a/cerbero/packages/linux_bundle.py
+++ b/cerbero/packages/linux_bundle.py
@@ -28,15 +28,33 @@ from cerbero.packages import PackagerBase
LAUNCH_BUNDLE_COMMAND = """# Try to discover plugins only once
+LOCKFILE="/tmp/%(appname)s-bundle.lock"
+if [ -e $LOCKFILE ]
+then
+ PID=$(cat $LOCKFILE)
+ if kill -0 $PID 2> /dev/null
+ then
+ echo "$? $PID pitivi already running -> exiting"
+ exit 1
+ else
+ echo "Stalled process $PID allow restarting"
+ fi
+fi
+echo $$ > $LOCKFILE
+
PLUGINS_SYMLINK=${HOME}/.cache/gstreamer-1.0/%(appname)s-gstplugins
+rm ${PLUGINS_SYMLINK} > /dev/null 2>&1
ln -s ${APPDIR}/lib/gstreamer-1.0/ ${PLUGINS_SYMLINK}
if [ $? -ne 0 ]; then
- echo "Bundle is already running, exiting"
- exit 1
+ export GST_PLUGIN_PATH=${APPDIR}/lib/gstreamer-1.0/
else
export GST_PLUGIN_PATH=${PLUGINS_SYMLINK}
fi
+trap 'ECODE=$?;
+ echo "[statsgen] Removing lock. Exit: ${ETXT[ECODE]}($ECODE)" >&2
+ rm "${PLUGINS_SYMLINK}" "${LOCKFILE}"' 0
+
which gdk-pixbuf-query-loaders > /dev/null 2>&1
if [ $? -eq 0 ]; then
export GDK_PIXBUF_MODULE_FILE=/tmp/$(basename $APPDIR).gdk-pixbuf-loader.cache