Quellcode durchsuchen

API-Hour FrameworkBenchmark: Update API-Hour Container to handle new config format

Ludovic Gasc (GMLudo) vor 10 Jahren
Ursprung
Commit
1c9dd8b90b

+ 0 - 1
frameworks/Python/API-Hour/api_hour_conf.py → frameworks/Python/API-Hour/hello/etc/hello/api_hour/gunicorn_conf.py

@@ -1,6 +1,5 @@
 import multiprocessing
 import os
-import sys
 
 _is_travis = os.environ.get('TRAVIS') == 'true'
 

+ 5 - 5
frameworks/Python/API-Hour/hello/etc/hello/logging.ini → frameworks/Python/API-Hour/hello/etc/hello/api_hour/logging.ini

@@ -31,7 +31,7 @@ formatter=detailed
 
 [logger_root]
 level=ERROR
-handlers=console,smtp,syslog
+handlers=console,syslog
 
 # You can add smtp in handlers list to receive e-mail alerts
 [logger_warnings]
@@ -41,25 +41,25 @@ qualname=py.warnings
 propagate=0
 
 [logger_asyncio]
-level=WARN
+level=INFO
 handlers=console,syslog
 qualname=asyncio
 propagate=0
 
 [logger_gunicorn]
-level=WARN
+level=INFO
 handlers=console,syslog
 qualname=gunicorn
 propagate=0
 
 [logger_aiohttp]
-level=WARN
+level=INFO
 handlers=console,syslog
 qualname=aiohttp
 propagate=0
 
 [logger_api_hour]
-level=WARN
+level=DEBUG
 handlers=console,syslog
 qualname=api_hour
 propagate=0

+ 0 - 21
frameworks/Python/API-Hour/hello/etc/hello/main.conf

@@ -1,21 +0,0 @@
-[main]
-    hostname = hello
-    host = 0.0.0.0
-    port = 5050
-    pid = /run/lock/hello
-    access_log_format = %(p)s %(h)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
-
-[engines]
-    [[pg]]
-        host = 127.0.0.1
-        port = 5432
-        dbname = hello_world
-        user = benchmarkdbuser
-        password = benchmarkdbpass
-        minsize = 20
-        maxsize = 20
-
-[performance]
-    # Don't change worker value, WIP, it can bite your wife and children
-    workers = 1
-    backlog = 1024

+ 9 - 0
frameworks/Python/API-Hour/hello/etc/hello/main/main.yaml

@@ -0,0 +1,9 @@
+engines:
+  pg:
+    host: 127.0.0.1
+    port: 5432
+    dbname: hello_world
+    user: benchmarkdbuser
+    password: benchmarkdbpass
+    minsize: 20
+    maxsize: 20

+ 1 - 1
frameworks/Python/API-Hour/hello/hello/__init__.py

@@ -39,7 +39,7 @@ class Container(api_hour.Container):
     def start(self):
         yield from super().start()
         LOG.info('Starting engines...')
-        self.engines['pg'] = self.loop.create_task(aiopg.create_pool(host=os.environ.get('DBHOST', '127.0.0.1'),
+        self.engines['pg'] = self.loop.create_task(aiopg.create_pool(host=os.environ.get('DBHOST', self.config['engines']['pg']['host']),
                                                                      sslmode='disable',
                                                                      port=int(self.config['engines']['pg']['port']),
                                                                      dbname=self.config['engines']['pg']['dbname'],

+ 2 - 1
frameworks/Python/API-Hour/requirements.txt

@@ -5,4 +5,5 @@ psycopg2==2.5.4
 setproctitle==1.1.8
 six==1.8.0
 ujson==1.33
-aiohttp==0.13.1
+aiohttp==0.13.1
+PyYAML==3.11

+ 1 - 1
frameworks/Python/API-Hour/setup.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-$PY3_API_HOUR -c api_hour_conf.py --chdir=hello/ --config_dir=hello/etc/hello/ hello:Container &
+$PY3_API_HOUR --chdir=hello/ --config_dir=hello/etc/hello/ hello:Container &

+ 3 - 2
frameworks/Python/API-Hour/source_code

@@ -1,5 +1,6 @@
-./API-Hour/etc/hello/main.conf
-./API-Hour/etc/hello/logging.ini
+./API-Hour/etc/hello/main/main.yaml
+./API-Hour/etc/hello/api_hour/logging.ini
+./API-Hour/etc/hello/api_hour/gunicorn_conf.py
 ./API-Hour/hello/__init__.py
 ./API-Hour/hello/hello/endpoints/__init__.py
 ./API-Hour/hello/hello/endpoints/world.py