コード例 #1
0
ファイル: srvr_jboxd.py プロジェクト: Emram/JuliaBox
    def run(self):
        Compute.deregister_instance_dns()
        Compute.register_instance_dns()
        JBoxd.publish_perf_counters()

        JBoxd.log_debug("Setting up signal handlers")
        signal.signal(signal.SIGINT, JBoxd.signal_handler)
        signal.signal(signal.SIGTERM, JBoxd.signal_handler)

        if VolMgr.has_update_for_user_home_image():
            VolMgr.update_user_home_image(fetch=False)

        while True:
            self.log_debug("JBox daemon waiting for commands...")
            try:
                offline, reply_req = JBoxd.QUEUE.poll(self._is_scheduled(JBoxAsyncJob.CMD_REQ_RESP, ()))
            except ValueError:
                self.log_exception("Exception reading command. Will retry after 10 seconds")
                time.sleep(10)
                continue

            if offline:
                try:
                    self.process_offline()
                except:
                    self.log_exception("Exception scheduling request")

            if reply_req:
                JBoxd.schedule_thread(JBoxAsyncJob.CMD_REQ_RESP, JBoxd.process_and_respond, ())
コード例 #2
0
ファイル: srvr_jboxd.py プロジェクト: Emram/JuliaBox
    def is_terminating():
        if not JBoxCfg.get('cloud_host.scale_down'):
            return False

        num_active = BaseContainer.num_active()
        terminate = (num_active == 0) and Compute.can_terminate(is_proposed_cluster_leader())

        if terminate:
            JBoxd.log_warn("terminating to scale down")
            try:
                Compute.deregister_instance_dns()
            except:
                JBoxd.log_error("Error deregistering instance dns")
            Compute.terminate_instance()

        return terminate