Skip to content

Commit

Permalink
Allow configuration file to be specified.
Browse files Browse the repository at this point in the history
Don't init SIP if it's not enabled.
  • Loading branch information
sobomax committed Jul 18, 2024
1 parent 1db2d63 commit 0898cf6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Infernos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0898cf6

Please sign in to comment.