def main(): # launchd on OS X seems to handle placing things in the background. # The default config for OS X prevents this script from running in the # the background. On Linux systems this value should be set to true. global channel if background == "True": doFork() wasConnected = False while True: growl = [] if wasConnected is True: wasConnected = False dencoderCommon.gNotify("Connection to AMQP server lost on %s" % (RabbitMQServer.getSelectedHost(), )) writePid() dencoderSetup() RabbitMQServer = dencoderAMQP.AMQPConnection() RabbitMQServer.setQueueName("encodejobs") if not RabbitMQServer: logger.info(' [*] connecting to RabbitMQ @%s' % (RabbitMQServer, )) try: logger.info(' [*] connected') except IOError: logger.critical(' [*] failed to connect to RabbitMQ!') logger.critical( ' [*] Please check RabbitMQ host and configuration') # waitAndSee() # check to see if paths exist # ensure that configured paths exist. If they don't, HandBrakeCLI will # immediately fail but as the script is currently written it'll still # ack the message. This ack tells RabbitMQ the encode was successful, # even though it wasn't if not checkPaths(): logger.critical( " [*] source path (%s) doesn't exist, is the file system mounted?" % (basePath + sourcePath, )) if sys.platform == "darwin": shutdownDencoder() else: waitAndSee() continue logger.debug(' [*] entering pika.asyncore_loop') logger.info(' [*] Waiting for encode jobs. Issue kill to %i to end' % (os.getpid(), )) dencoderCommon.gNotify( 'Dencoder on %s is now available for encoding jobs' % (dencoderCommon.hostname(), )) wasConnected = True RabbitMQServer.doLoop()
def shutdownDencoder(): dencoderCommon.gNotify('Dencoder on %s is shutting down' % (dencoderCommon.hostname(),) ) logger.info(' [*] SIGTERM received') logger.info(' [*] shutting down...') logger.info(' [*] terminating any running encodes...') disconnectRabbitMQ(dencoderCommon.channel) stopEncodes() logger.info(' [*] good bye') exit()
def main(): # launchd on OS X seems to handle placing things in the background. # The default config for OS X prevents this script from running in the # the background. On Linux systems this value should be set to true. global channel if background == "True": doFork() wasConnected = False while True: growl = [] if wasConnected is True: wasConnected = False dencoderCommon.gNotify("Connection to AMQP server lost on %s" % (RabbitMQServer.getSelectedHost(),)) writePid() dencoderSetup() RabbitMQServer = dencoderAMQP.AMQPConnection() RabbitMQServer.setQueueName("encodejobs") if not RabbitMQServer: logger.info(' [*] connecting to RabbitMQ @%s' %(RabbitMQServer,)) try: logger.info(' [*] connected') except IOError: logger.critical(' [*] failed to connect to RabbitMQ!') logger.critical(' [*] Please check RabbitMQ host and configuration') # waitAndSee() # check to see if paths exist # ensure that configured paths exist. If they don't, HandBrakeCLI will # immediately fail but as the script is currently written it'll still # ack the message. This ack tells RabbitMQ the encode was successful, # even though it wasn't if not checkPaths(): logger.critical(" [*] source path (%s) doesn't exist, is the file system mounted?" % (basePath + sourcePath,)) if sys.platform == "darwin": shutdownDencoder() else: waitAndSee() continue logger.debug(' [*] entering pika.asyncore_loop') logger.info(' [*] Waiting for encode jobs. Issue kill to %i to end' % (os.getpid(),)) dencoderCommon.gNotify('Dencoder on %s is now available for encoding jobs' % (dencoderCommon.hostname(),)) wasConnected = True RabbitMQServer.doLoop()
def shutdownDencoder(): dencoderCommon.gNotify('Dencoder on %s is shutting down' % (dencoderCommon.hostname(), )) logger.info(' [*] SIGTERM received') logger.info(' [*] shutting down...') logger.info(' [*] terminating any running encodes...') disconnectRabbitMQ(dencoderCommon.channel) stopEncodes() logger.info(' [*] good bye') exit()