コード例 #1
0
ファイル: main.py プロジェクト: osiloke/Flumotion-Transcoder
def possess(daemonizeTo=None):
    fileutils.ensureDirExists(configure.logdir, "log file")
    fileutils.ensureDirExists(configure.rundir, "run file")
    if not daemonizeTo:
        daemonizeTo = '/'

    pid = process.getPid('transcoder-admin')
    if pid:
        if process.checkPidRunning(pid):
            raise iherrors.SystemError(
                'A flumotion-transcoder-admin is already running '
                + 'as pid %d' % pid)
        else:
            log.warning("flumotion-transcoder-admin should have been "
                        "running with pid %s.  Restarting", str(pid))
            process.deletePidFile('transcoder-admin')

    logPath = os.path.join(configure.logdir, 'transcoder-admin.log')

    # here we daemonize; so we also change our pid
    if not daemonizeTo:
        daemonizeTo = '/'
    process.daemonize(stdout=logPath, stderr=logPath,
                      directory=daemonizeTo)

    log.info('Started daemon')

    # from now on I should keep running, whatever happens
    log.debug('writing pid file')
    process.writePidFile('transcoder-admin')
コード例 #2
0
def notifyDebug(msg, info=None, debug=None, failure=None,
                exception=None, documents=None):
    """
    This function can be used from anywere to notify
    debug information (like traceback) when no
    Notifier reference is available.
    Do not raise any exception.
    """
    global _shutingDown
    if _shutingDown: return
    try:
        sender = _debugSender
        recipients = _debugRecipients
        log.info("Try sending a debug notification to %s from %s",
                 recipients, sender,
                 category=adminconsts.NOTIFIER_LOG_CATEGORY)
        body = _buildBody(sender, recipients, msg, msg, info, debug,
                          failure, exception, documents)
        d = _postNotification(_smtpServer, _smtpPort, _smtpRequireTLS,
                              sender, recipients, body)
        args = ("Debug",)
        d.addCallbacks(_cbNotificationDone, _ebNotificationFailed,
                       callbackArgs=args, errbackArgs=args)
    except Exception, e:
        log.warning("Debug Notification Failed: %s",
                    log.getExceptionMessage(e),
                    category=adminconsts.NOTIFIER_LOG_CATEGORY)
コード例 #3
0
ファイル: main.py プロジェクト: osiloke/Flumotion-Transcoder
def main(args):
    log.setDefaultCategory(adminconsts.ADMIN_LOG_CATEGORY)
    log.setDebugNotifier(notifier.notifyDebug)

    options, configPath = parse_options(args)

    loader = inifile.IniFile()
    config = adminconfig.ClusterConfig()
    try:
        loader.loadFromFile(config, configPath)
    except Exception, e:
        sys.stderr.write('Error: %s\n' % e)
        sys.exit(1)

    debug = options.debug or config.debug
    if debug:
        log.setFluDebug(debug)

    if options.daemonize:
        possess(options.daemonizeTo)

    a = admin.TranscoderAdmin(config)
    utils.callNext(a.initialize)
    reactor.run()

    if options.daemonize:
        exorcize()

    log.info('Stopping transcoder-admin')
コード例 #4
0
def _disableNotification():
    global _shutingDown
    _shutingDown = True
    log.info("Disabling notifications during shutdown",
             category=adminconsts.NOTIFIER_LOG_CATEGORY)
コード例 #5
0
def _cbNotificationDone(result, kind):
    log.info("%s notification sent", kind,
             category=adminconsts.NOTIFIER_LOG_CATEGORY)