Revision 88a10df5 htools/Ganeti/Daemon.hs

b/htools/Ganeti/Daemon.hs
171 171
    (opt_list, args, []) ->
172 172
      do
173 173
        parsed_opts <-
174
          case foldM (flip id) defaultOptions opt_list of
175
            Bad msg -> do
176
              hPutStrLn stderr "Error while parsing command\
177
                               \line arguments:"
178
              hPutStrLn stderr msg
179
              exitWith $ ExitFailure 1
180
            Ok val -> return val
174
          exitIfBad "Error while parsing command line arguments" $
175
          foldM (flip id) defaultOptions opt_list
181 176
        return (parsed_opts, args)
182 177
    (_, _, errs) -> do
183 178
      hPutStrLn stderr $ "Command line error: "  ++ concat errs
......
291 286
           compilerName (Data.Version.showVersion compilerVersion)
292 287
           os arch :: IO ()
293 288
    exitWith ExitSuccess
294
  unless (null args) $ do
295
         hPutStrLn stderr "This program doesn't take any arguments"
296
         exitWith $ ExitFailure C.exitFailure
289

  
290
  exitUnless (null args) "This program doesn't take any arguments"
297 291

  
298 292
  unless (optNoUserChecks opts) $ do
299 293
    runtimeEnts <- getEnts
300
    case runtimeEnts of
301
      Bad msg -> do
302
        hPutStrLn stderr $ "Can't find required user/groups: " ++ msg
303
        exitWith $ ExitFailure C.exitFailure
304
      Ok ents -> verifyDaemonUser daemon ents
294
    ents <- exitIfBad "Can't find required user/groups" runtimeEnts
295
    verifyDaemonUser daemon ents
305 296

  
306 297
  syslog <- case optSyslogUsage opts of
307
              Nothing -> exitIfBad $
308
                         annotateResult "Invalid cluster syslog setting" $
298
              Nothing -> exitIfBad "Invalid cluster syslog setting" $
309 299
                         syslogUsageFromRaw C.syslogUsage
310 300
              Just v -> return v
311 301
  let processFn = if optDaemonize opts then daemonize else id
......
319 309
  setupLogging (daemonLogFile daemon) (daemonName daemon) (optDebug opts)
320 310
                 (not (optDaemonize opts)) False syslog
321 311
  pid_fd <- writePidFile (daemonPidFile daemon)
322
  case pid_fd of
323
    Bad msg -> do
324
         hPutStrLn stderr $ "Cannot write PID file; already locked? Error: " ++
325
                   msg
326
         exitWith $ ExitFailure 1
327
    _ -> return ()
312
  _ <- exitIfBad "Cannot write PID file; already locked? Error" pid_fd
328 313
  logNotice "starting"
329 314
  main

Also available in: Unified diff