コード例 #1
0
ファイル: os.py プロジェクト: JasonGiedymin/py-service-os
    def start(self):
        BaseService.start(self)
        self.get_directory_service_proxy().start()

        self.log.info("starting services...")
        self.monitor_services()

        return self.greenlet
コード例 #2
0
    def start(self):
        BaseService.start(self)
        self.get_directory_service_proxy().start()

        self.log.info("starting services...")
        self.monitor_services()

        return self.greenlet
コード例 #3
0
ファイル: os.py プロジェクト: JasonGiedymin/py-service-os
 def start(self):
     """
     Starts the scheduler, which by default starts
     the service manager. They work hand in hand.
     :return:
     """
     BaseService.start(self)
     self.service_manager.start()
     return self.greenlet
コード例 #4
0
 def start(self):
     """
     Starts the scheduler, which by default starts
     the service manager. They work hand in hand.
     :return:
     """
     BaseService.start(self)
     self.service_manager.start()
     return self.greenlet
コード例 #5
0
def test_baseservice():
    """
    Base service tests for:
        - [x] name on init
        - [x] idle state on init
        - [x] starting state on start()
        - [x] ready() alias for idle state
        - [x] stopped state on stop()
        - [x] idle state exception when service not in stopped state
        - [x] idle state on idle()
    :return:
    """

    name = "base-service-1"
    base = BaseService(name)
    assert base.alias == name
    assert base.unique_name == '%s/%s' % (name, base.uuid)
    assert base.get_state() == BaseStates.Idle
    assert base.ready() is True  # ready == Idle

    greenlet = base.start()
    assert greenlet is not None
    assert base.get_state() == BaseStates.Starting
    assert base.ready() is False

    # exception should be thrown if state is started
    # and asking service to make itself idle.
    try:
        base.idle()
    except IdleActionException as ex:
        assert ex is not None

    base.stop()
    assert base.get_state() == BaseStates.Stopped

    # Try restarting the service, it will fail because it is not idle
    # In order to restart a service must be set to idle again.
    try:
        base.start()
        assert not True  # <-- should never get here
    except ServiceNotIdleException as ex:
        assert ex is not None

    # now set to idle
    base.idle()  # should not throw this time
    assert base.get_state() == BaseStates.Idle

    # not start, should work and not throw an exception
    base.start()
コード例 #6
0
def test_baseservice_service_directory():
    """
    Base service tests for:
        - [x] name on init
        - [x] idle state on init
        - [x] started state on start()
        - [x] ready() alias for idle state
        - [x] stopped state on stop()
        - [x] idle state exception when service not in stopped state
        - [x] idle state on idle()
    :return:
    """

    name = "base-service-1"
    base = BaseService(name)
    assert base.alias == name
    assert base.unique_name == '%s/%s' % (name, base.uuid)
    assert base.get_state() == BaseStates.Idle
    assert base.ready() is True  # ready == Idle

    greenlet = base.start()
    assert greenlet is not None
    assert base.get_state() == BaseStates.Starting
    assert base.ready() is False

    # exception should be thrown if state is started
    # and asking service to make itself idle.
    try:
        base.idle()
    except IdleActionException as ex:
        assert ex is not None

    base.stop()
    assert base.get_state() == BaseStates.Stopped
    base.idle()  # should not throw this time
    assert base.get_state() == BaseStates.Idle