From 0898cf6713b3d9e45886cca2606cf22ded4a1985 Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Wed, 17 Jul 2024 19:31:14 -0700 Subject: [PATCH] Allow configuration file to be specified. Don't init SIP if it's not enabled. --- Infernos.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Infernos.py b/Infernos.py index dc2bd28..fcddb78 100644 --- a/Infernos.py +++ b/Infernos.py @@ -27,12 +27,21 @@ def _start_new_thread(*args): _old_start_new_thread = threading._start_new_thread threading._start_new_thread = _start_new_thread +def usage(): + print('usage: Infernos.py [-f] [-L logfile] [-i pidfile] [myconfig.yaml]') + sys.exit(1) + if __name__ == '__main__': try: opts, args = getopt(sys.argv[1:], 'fL:i:') except GetoptError: - print('usage: Infernos.py [-f] [-L logfile] [-i pidfile] config.yaml') - sys.exit(1) + usage() + + if len(args) > 1: + usage() + + cfile = 'config.yaml' if len(args) == 0 else args[0] + idir = os.path.realpath(sys.argv[0]) idir = os.path.dirname(idir) sys.path.append(idir) @@ -79,13 +88,17 @@ def _start_new_thread(*args): if str(ex).index('connecting to an existing cluster') < 0: raise ex ray.init() - inf_c = InfernConfig('config.yaml') + inf_c = InfernConfig(cfile) if pidfile != None: open(pidfile, 'w').write('%d' % os.getpid()) inf_c.sip_conf.logger = SipLogger('Infernos', logfile = os.path.expanduser('~/.Infernos.log')) + if inf_c.sip_actr is None: + ray.shutdown() + exit(0) + try: exit(ray.get(inf_c.sip_actr.loop.remote(inf_c))) except KeyboardInterrupt: