def test_existing_lock(self, mock_kill): """ Test that an existing lock will kill the old pid. """ l1 = Lock('test') self.assertTrue(isfile(get_temp_path('mycroft', 'test.pid'))) l2 = Lock('test2') self.assertFalse(mock_kill.called) l2 = Lock('test') self.assertTrue(mock_kill.called)
def main(): global ws lock = Lock('skills') # prevent multiple instances of this service # Connect this Skill management process to the websocket ws = WebsocketClient() ConfigurationManager.init(ws) ignore_logs = ConfigurationManager.instance().get("ignore_logs") # Listen for messages and echo them for logging def _echo(message): try: _message = json.loads(message) if _message.get("type") in ignore_logs: return if _message.get("type") == "registration": # do not log tokens from registration messages _message["data"]["token"] = None message = json.dumps(_message) except: pass LOG('SKILLS').debug(message) ws.on('message', _echo) ws.on('skill.converse.request', handle_converse_request) # Startup will be called after websocket is full live ws.once('open', _starting_up) ws.run_forever()
def main(): global ws lock = Lock('skills') # prevent multiple instances of this service # Connect this Skill management process to the websocket ws = WebsocketClient() ConfigurationManager.init(ws) ignore_logs = ConfigurationManager.instance().get("ignore_logs") # Listen for messages and echo them for logging def _echo(message): try: _message = json.loads(message) if _message.get("type") in ignore_logs: return if _message.get("type") == "registration": # do not log tokens from registration messages _message["data"]["token"] = None message = json.dumps(_message) except: pass logger.debug(message) ws.on('message', _echo) # Kick off loading of skills ws.once('open', _load_skills) ws.run_forever()
def main(): rospy.init_node('mycroft_message_bus') rospy.loginfo(rospy.get_caller_id() + " started") import tornado.options reset_sigint_handler() lock = Lock("service") tornado.options.parse_command_line() def reload_hook(): """ Hook to release lock when autoreload is triggered. """ lock.delete() autoreload.add_reload_hook(reload_hook) config = Configuration.get().get("websocket") host = config.get("host") port = config.get("port") route = config.get("route") validate_param(host, "websocket.host") validate_param(port, "websocket.port") validate_param(route, "websocket.route") routes = [(route, WebsocketEventHandler)] application = web.Application(routes, **settings) application.listen(port, host) create_daemon(ioloop.IOLoop.instance().start) wait_for_exit_signal() rospy.spin()
def test_keyboard_interrupt(self): l1 = Lock('test') self.assertTrue(isfile(get_temp_path('mycroft', 'test.pid'))) try: os.kill(os.getpid(), signal.SIGINT) except KeyboardInterrupt: pass self.assertFalse(isfile(get_temp_path('mycroft', 'test.pid')))
def main(*args, **kwargs): # Initialize configuration init_config_dir() if kwargs.get("config"): from neon_speech.utils import patch_config patch_config(kwargs.pop("config")) from mycroft.lock import Lock from mycroft.util.process_utils import reset_sigint_handler from neon_speech.service import NeonSpeechClient reset_sigint_handler() Lock("speech") service = NeonSpeechClient(*args, **kwargs) service.start() wait_for_exit_signal() service.shutdown()
def main(): import tornado.options lock = Lock("service") tornado.options.parse_command_line() config = ConfigurationManager.get().get("websocket") host = config.get("host") port = config.get("port") route = config.get("route") validate_param(host, "websocket.host") validate_param(port, "websocket.port") validate_param(route, "websocket.route") routes = [(route, WebsocketEventHandler)] application = web.Application(routes, **settings) application.listen(port, host) ioloop.IOLoop.instance().start()
def main(): import tornado.options LOG.info('Starting message bus service...') reset_sigint_handler() lock = Lock("service") # Disable all tornado logging so mycroft loglevel isn't overridden tornado.options.parse_command_line(sys.argv + ['--logging=None']) def reload_hook(): """ Hook to release lock when auto reload is triggered. """ lock.delete() autoreload.add_reload_hook(reload_hook) config = load_message_bus_config() routes = [(config.route, MessageBusEventHandler)] application = web.Application(routes, debug=True) application.listen(config.port, config.host) create_daemon(ioloop.IOLoop.instance().start) LOG.info('Message bus service started!') wait_for_exit_signal()
def main(): import tornado.options lock = Lock("service") tornado.options.parse_command_line() def reload_hook(): """ Hook to release lock when autoreload is triggered. """ lock.delete() tornado.autoreload.add_reload_hook(reload_hook) config = ConfigurationManager.get().get("websocket") host = config.get("host") port = config.get("port") route = config.get("route") validate_param(host, "websocket.host") validate_param(port, "websocket.port") validate_param(route, "websocket.route") routes = [(route, WebsocketEventHandler)] application = web.Application(routes, **settings) application.listen(port, host) ioloop.IOLoop.instance().start()
def test_delete_lock(self): l1 = Lock('test') self.assertTrue(isfile(get_temp_path('mycroft', 'test.pid'))) l1.delete() self.assertFalse(isfile(get_temp_path('mycroft', 'test.pid')))
def test_create_lock(self): l1 = Lock('test') self.assertTrue(isfile(get_temp_path('mycroft', 'test.pid')))
def test_delete_lock(self): l1 = Lock('test') self.assertTrue(isfile('/tmp/mycroft/test.pid')) l1.delete() self.assertFalse(isfile('/tmp/mycroft/test.pid'))
def test_create_lock(self): l1 = Lock('test') self.assertTrue(isfile('/tmp/mycroft/test.pid'))