Exemplo n.º 1
0
    def execute(self, args):
        project = Project.from_file(self.workspace,
                                    self.workspace.startup_directory)
        with project.paths_set():
            try:
                if args.restart:
                    ServerSupervisor(sys.argv[1:] + ['--dont-restart'],
                                     args.max_seconds_between_restarts,
                                     ['.'] + args.monitored_directories).run()
                else:
                    config_directory = args.config_directory
                    six.print_('\nUsing config from %s\n' % config_directory,
                               flush=True)

                    try:
                        reahl_server = ReahlWebServer.fromConfigDirectory(
                            config_directory, args.port)
                    except pkg_resources.DistributionNotFound as ex:
                        terminate_keys = 'Ctrl+Break' if platform.system(
                        ) == 'Windows' else 'Ctrl+C'
                        six.print_('\nPress %s to terminate\n\n' %
                                   terminate_keys,
                                   flush=True)
                        raise CouldNotConfigureServer(ex)

                    reahl_server.start(connect=True)
                    six.print_('\n\nServing http on port %s, https on port %s (config=%s, flush=True)' % \
                                     (args.port, args.port+363, config_directory))
                    terminate_keys = 'Ctrl+Break' if platform.system(
                    ) == 'Windows' else 'Ctrl+C'
                    six.print_('\nPress %s to terminate\n\n' % terminate_keys,
                               flush=True)

                    notify = Executable('notify-send')
                    try:
                        notify.call(['Reahl', 'Server restarted'])
                    except:
                        pass

                    reahl_server.wait_for_server_to_complete()
            except KeyboardInterrupt:
                six.print_('\nShutting down', flush=True)
            except CouldNotConfigureServer as ex:
                six.print_(ex, flush=True)
        return 0
Exemplo n.º 2
0
 def new_supervisor(self):
     supervisor = ServerSupervisor(EmptyStub(), 0, directories_to_monitor=[self.dir_to_watch.name])
     supervisor.serving_process = SlaveProcessStartCounterStub()
     return supervisor