etwist/server.py
changeset 2711 7aee3bd7a704
parent 2708 60d728bdcba5
child 2770 356e9d7c356d
child 3115 29262ba01464
child 3181 735c5f9fcded
--- a/etwist/server.py	Wed Aug 05 19:14:39 2009 +0200
+++ b/etwist/server.py	Thu Aug 06 09:04:26 2009 +0200
@@ -370,6 +370,11 @@
     if not debug:
         daemonize()
         if config['pid-file']:
+            # ensure the directory where the pid-file should be set exists (for
+            # instance /var/run/cubicweb may be deleted on computer restart)
+            piddir = os.path.dirname(config['pid-file'])
+            if not os.path.exists(piddir):
+                os.makedirs(piddir)
             file(config['pid-file'], 'w').write(str(os.getpid()))
     if config['profile']:
         prof = hotshot.Profile(config['profile'])