def run(self):
        from posixpath import basename
        import signal

        super().run()

        # Docker builder (if needed)
        service = Service(self.hutcfg, self.usercfg.username)
        service.build_push(force=self.force)

        docker = get_docker()
        log.info("Running service '{}' on http://{}:{}".
                 format(self.hutcfg.service_short_name(self.usercfg.username), docker.ip, self.port))
        log.info("Test by running 'curl -H \"Content-Type: application/json\" -X POST -d @test_request.json "
                 "http://{}:{}/run' from the '{}' dir".format(docker.ip, self.port, basename(utils.ROOT_DIR)))

        # setup shutdown handlers - needed for freeze?
        signal.signal(signal.SIGTERM, self.sigterm_handler)
        signal.signal(signal.SIGINT, self.sigterm_handler)

        try:
            with RunService(self.port, self.args, self.usercfg.username, service.full_name) as sh_service:
                sh_service.start()
                if self.test:
                    time.sleep(2)
                    TestRequestCmd(self.args).run()
                else:
                    log.debug("Waiting for sh_service")
                    sh_service.p.wait()

        except __HOLE__:
            log.debug("Shutting down service container, press again to force-quit...")

        log.info("Run completed successfully")
        return 0
dataset/ETHPy150Open StackHut/stackhut/stackhut_toolkit/run_commands.py/RunContainerCmd.run