[projects/git-slug: 89/170] Remove lock file when SIGTERM is received
glen
glen at pld-linux.org
Mon Sep 21 21:46:17 CEST 2015
commit 94efc889aa67026458490a8ab06373657a2c838c
Author: Kacper Kornet <draenog at pld-linux.org>
Date: Tue Mar 13 08:17:00 2012 +0000
Remove lock file when SIGTERM is received
slug_watch | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/slug_watch b/slug_watch
index bff899e..f82e3f0 100755
--- a/slug_watch
+++ b/slug_watch
@@ -6,6 +6,7 @@ import heapq
import os
import pwd
import pyinotify
+import signal
from contextlib import contextmanager
@@ -22,8 +23,12 @@ REFREPO_GDIR = os.path.join('repositories', REFREPO+'.git')
WATCHDIR=WATCHDIR
+def sigtermhandler(no, stack):
+ raise SystemExit
+
@contextmanager
def lock(path=LOCKFILE):
+ signal.signal(signal.SIGTERM, sigtermhandler)
f = open(path, 'a')
try:
fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5
More information about the pld-cvs-commit
mailing list