summaryrefslogtreecommitdiffstats
path: root/gitautodeploy/gitautodeploy.py
diff options
context:
space:
mode:
authorVlad Ionescu <vlad@vladionescu.com>2016-05-25 15:07:01 -0700
committerVlad Ionescu <vlad@vladionescu.com>2016-05-25 15:07:01 -0700
commite707129cd9e427560cb8fa8884026fcbefbfa3a7 (patch)
tree2699b87f630f06b54b4ce5301a56371705a1543f /gitautodeploy/gitautodeploy.py
parent6dc1656f4bfec511405d36973b68538aa95b26a7 (diff)
downloadGit-Auto-Deploy-e707129cd9e427560cb8fa8884026fcbefbfa3a7.zip
Git-Auto-Deploy-e707129cd9e427560cb8fa8884026fcbefbfa3a7.tar.gz
Git-Auto-Deploy-e707129cd9e427560cb8fa8884026fcbefbfa3a7.tar.bz2
Windows does not support all of *nix's signals, so check before...
Relying on them. The Python documentation mentions which signals are supported (emulated, really) on Windows. "On Windows, signal() can only be called with SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError will be raised in any other case." From https://docs.python.org/3/library/signal.html#signal.signal
Diffstat (limited to 'gitautodeploy/gitautodeploy.py')
-rw-r--r--gitautodeploy/gitautodeploy.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/gitautodeploy/gitautodeploy.py b/gitautodeploy/gitautodeploy.py
index f24ec6e..a520a91 100644
--- a/gitautodeploy/gitautodeploy.py
+++ b/gitautodeploy/gitautodeploy.py
@@ -160,7 +160,13 @@ class GitAutoDeploy(object):
logger.warning('No process is currently using port %s.' % self._config['port'])
return False
- os.kill(pid, signal.SIGKILL)
+ if hasattr(signal, SIGKILL):
+ os.kill(pid, signal.SIGKILL)
+ elif hasattr(signal, SIGHUP):
+ os.kill(pid, signal.SIGHUP)
+ else:
+ os.kill(pid, 1)
+
return True
def create_pid_file(self):
@@ -410,10 +416,14 @@ def main():
app = GitAutoDeploy()
- signal.signal(signal.SIGHUP, app.signal_handler)
- signal.signal(signal.SIGINT, app.signal_handler)
- signal.signal(signal.SIGABRT, app.signal_handler)
- signal.signal(signal.SIGPIPE, signal.SIG_IGN)
+ if hasattr(signal, SIGHUP):
+ signal.signal(signal.SIGHUP, app.signal_handler)
+ if hasattr(signal, SIGINT):
+ signal.signal(signal.SIGINT, app.signal_handler)
+ if hasattr(signal, SIGABRT):
+ signal.signal(signal.SIGABRT, app.signal_handler)
+ if hasattr(signal, SIGPIPE) and hasattr(signal, SIG_IGN):
+ signal.signal(signal.SIGPIPE, signal.SIG_IGN)
config = get_config_defaults()