Browse Source

[2447] catch failure on initial log, which is most likely a permission issue.

so, it now just prints some hints to stderr and exits.
JINMEI Tatuya 12 years ago
parent
commit
88c9fb48d7
1 changed files with 15 additions and 3 deletions
  1. 15 3
      src/bin/bind10/bind10_src.py.in

+ 15 - 3
src/bin/bind10/bind10_src.py.in

@@ -1145,6 +1145,21 @@ def main():
 
     options = parse_args()
 
+    # Announce startup.  Making this is the first log message.
+    try:
+        logger.info(BIND10_STARTING, VERSION)
+    except RuntimeError as e:
+        sys.stderr.write('ERROR: failed to write the initial log: %s\n' %
+                         str(e))
+        sys.stderr.write("""\
+TIP: if this is about permission error for a lock file, check if the directory
+of the file is writable for the user of the bind10 process; often you need
+to start bind10 as a super user.  Also, if you specify the -u option to
+change the user and group, the directory must be writable for the group,
+and the created lock file must be writabel for that user.
+""")
+        sys.exit(1)
+
     # Check user ID.
     setuid = None
     setgid = None
@@ -1177,9 +1192,6 @@ def main():
             logger.fatal(BIND10_INVALID_USER, options.user)
             sys.exit(1)
 
-    # Announce startup.
-    logger.info(BIND10_STARTING, VERSION)
-
     # Create wakeup pipe for signal handlers
     wakeup_pipe = os.pipe()
     signal.set_wakeup_fd(wakeup_pipe[1])