summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-07-25 19:18:50 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-07-25 19:18:50 +0200
commit5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6 (patch)
treeb1bdca0bb1c959913188cd887cc1ec353c27f60f
parentbf08c26ec6e30575092b5c213d460ae1ae92c70a (diff)
downloadbot-5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6.tar.gz
bot-5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6.tar.bz2
bot-5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6.zip
add pid setting for config to specify a pid path
-rwxr-xr-x__init__.py10
-rwxr-xr-xphenny3
2 files changed, 11 insertions, 2 deletions
diff --git a/__init__.py b/__init__.py
index 5699583..b33d0cf 100755
--- a/__init__.py
+++ b/__init__.py
@@ -12,9 +12,15 @@ import bot
class Watcher(object):
# Cf. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496735
- def __init__(self):
+ def __init__(self, config):
self.child = os.fork()
if self.child != 0:
+ if config.pid is not None:
+ f = open(config.pid, 'w')
+ try:
+ f.write(str(self.child))
+ finally:
+ f.close()
self.watch()
def watch(self):
@@ -36,7 +42,7 @@ def run_phenny(config):
p = bot.Phenny(config)
p.run(config.host, config.port)
- try: Watcher()
+ try: Watcher(config)
except Exception, e:
print >> sys.stderr, 'Warning:', e, '(in __init__.py)'
diff --git a/phenny b/phenny
index 1bc110b..6a6a131 100755
--- a/phenny
+++ b/phenny
@@ -148,6 +148,9 @@ def main(argv=None):
if not hasattr(module, 'password'):
module.password = None
+ if not hasattr(module, 'pid'):
+ module.pid = None
+
if module.host == 'irc.example.net':
error = ('Error: you must edit the config file first!\n' +
"You're currently using %s" % module.filename)