Ejemplo n.º 1
0
 def run(self, handler):
     from cheroot.wsgi import Server as WSGIServer
     from cheroot.ssl.pyopenssl import pyOpenSSLAdapter
     server = WSGIServer((self.host, self.port), handler)
     server.ssl_adapter = pyOpenSSLAdapter(
         certificate=SolUtils.AppConfig().get('solserver_certificate'),
         private_key=SolUtils.AppConfig().get('solserver_private_key'),
     )
     try:
         server.start()
         log.info("Server started")
     finally:
         server.stop()
Ejemplo n.º 2
0
    def __init__(self):

        # local variables
        self.sites = []
        self.influxClient = influxdb.client.InfluxDBClient(
            host=SolUtils.AppConfig().get('influxdb_host'),
            port=SolUtils.AppConfig().get('influxdb_port'),
            database=SolUtils.AppConfig().get('influxdb_database'),
        )
        self.actions = []

        # initialize web server
        self.web = bottle.Bottle()
        # interaction with SolManager
        self.web.route(
            path='/api/v1/o.json',
            method='PUT',
            callback=self._webhandle_o_PUT,
        )
        self.web.route(
            path='/api/v1/getactions/',
            method='GET',
            callback=self._webhandle_getactions_GET,
        )
        # interaction with administrator
        self.web.route(
            path='/api/v1/echo.json',
            method='POST',
            callback=self._webhandle_echo_POST,
        )
        self.web.route(
            path='/api/v1/status.json',
            method='GET',
            callback=self._webhandle_status_GET,
        )
        self.web.route(
            path='/api/v1/setaction/',
            method='POST',
            callback=self._webhandle_setactions_POST,
        )

        # start the thread
        threading.Thread.__init__(self)
        self.name = 'JsonApiThread'
        self.daemon = True
        self.start()
Ejemplo n.º 3
0
    def run(self):
        try:
            self.web.run(
                host='0.0.0.0',
                port=SolUtils.AppConfig().get('solserver_tcpport'),
                server=self.HTTPSServer,
                quiet=True,
                debug=False,
            )

        except bottle.BottleException:
            raise

        except Exception as err:
            SolUtils.logCrash(err, SolUtils.AppStats(), threadName=self.name)

        log.info("JsonApiThread started")
Ejemplo n.º 4
0
    def __init__(self):

        # init Singletons -- must be first init
        SolUtils.AppConfig(config_file=CONFIGFILE)
        SolUtils.AppStats(stats_file=STATSFILE, stats_list=ALLSTATS)

        # API thread
        self.jsonApiThread = JsonApiThread()

        # CLI interface
        self.cli = DustCli.DustCli("SolServer", self._clihandle_quit)
        self.cli.registerCommand(
            name='stats',
            alias='s',
            description='print the stats',
            params=[],
            callback=self._clihandle_stats,
        )