X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fserver%2Fsfa-start.py;h=7b2f19d0b83eaa5cd0db6c4aa6eca3a47bd3a715;hb=cea205b4982edebf6efe03f4b4dfda706b7592fa;hp=ba63da1f823f96651b92c81c124512344ba4c1cb;hpb=fe078a6fed085fdc81c1b29c619188866ca0c12b;p=sfa.git diff --git a/sfa/server/sfa-start.py b/sfa/server/sfa-start.py index ba63da1f..7b2f19d0 100755 --- a/sfa/server/sfa-start.py +++ b/sfa/server/sfa-start.py @@ -1,4 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/python3 -u +# now that logs are managed through stdout and journalctl, +# it is important to run with -u so that they show up quickly +# and don't get buffered # # PlanetLab SFA implementation # @@ -48,31 +51,6 @@ from sfa.server.aggregate import Aggregates from sfa.client.return_value import ReturnValue -def daemon(): - """ - Daemonize the current process. - after http://www.erlenstar.demon.co.uk/unix/faq_2.html - """ - if os.fork() != 0: - os._exit(0) - os.setsid() - if os.fork() != 0: - os._exit(0) - os.umask(0) - devnull = os.open(os.devnull, os.O_RDWR) - os.dup2(devnull, 0) - # xxx fixme - this is just to make sure that nothing gets stupidly lost - - # should use devnull - logdir = '/var/log/httpd' - # when installed in standalone we might not have httpd installed - if not os.path.isdir(logdir): - os.mkdir('/var/log/httpd') - crashlog = os.open('%s/sfa_access_log' % logdir, - os.O_RDWR | os.O_APPEND | os.O_CREAT, 0644) - os.dup2(crashlog, 1) - os.dup2(crashlog, 2) - - def install_peer_certs(server_key_file, server_cert_file): """ Attempt to install missing trusted gids and db records for @@ -85,7 +63,7 @@ def install_peer_certs(server_key_file, server_cert_file): api = SfaApi(key_file=server_key_file, cert_file=server_cert_file) registries = Registries() aggregates = Aggregates() - interfaces = dict(registries.items() + aggregates.items()) + interfaces = dict(list(registries.items()) + list(aggregates.items())) gids_current = api.auth.trusted_cert_list hrns_current = [gid.get_hrn() for gid in gids_current] hrns_expected = set([hrn for hrn in interfaces]) @@ -189,8 +167,6 @@ def main(): parser.add_option("-t", "--trusted-certs", dest="trusted_certs", action="store_true", help="refresh trusted certs", default=False) - parser.add_option("-d", "--daemon", dest="daemon", action="store_true", - help="Run as daemon.", default=False) (options, args) = parser.parse_args() config = Config() @@ -206,8 +182,6 @@ def main(): # ensure interface cert is present in trusted roots dir trusted_roots = TrustedRoots(config.get_trustedroots_dir()) trusted_roots.add_gid(GID(filename=server_cert_file)) - if (options.daemon): - daemon() if options.trusted_certs: install_peer_certs(server_key_file, server_cert_file)