server/serverctl.py
changeset 2711 7aee3bd7a704
parent 2682 0188a4a02403
child 2790 968108e16066
child 2837 65df5df190a5
--- a/server/serverctl.py	Wed Aug 05 19:14:39 2009 +0200
+++ b/server/serverctl.py	Thu Aug 06 09:04:26 2009 +0200
@@ -458,7 +458,13 @@
         # create the server
         server = RepositoryServer(config, debug)
         # go ! (don't daemonize in debug mode)
-        if not debug and server.daemonize(config['pid-file']) == -1:
+        pidfile = 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(pidfile)
+        if not os.path.exists(piddir):
+            os.makedirs(piddir)
+        if not debug and server.daemonize(pidfile) == -1:
             return
         uid = config['uid']
         if uid is not None: