Page MenuHomeSoftware Heritage

D26.id77.diff
No OneTemporary

D26.id77.diff

diff --git a/swh/storage/api/server.py b/swh/storage/api/server.py
--- a/swh/storage/api/server.py
+++ b/swh/storage/api/server.py
@@ -5,6 +5,7 @@
import json
import logging
+import click
from flask import Flask, g, request
@@ -238,11 +239,16 @@
return app(environ, start_response)
-if __name__ == '__main__':
- import sys
+@click.command()
+@click.argument('config-path', required=1)
+@click.option('--host', default='0.0.0.0', help="Host to run the server")
+@click.option('--port', default=5000, help="Binding port of ther server")
+@click.option('--debug/--nodebug', default=True,
+ help="Indicates if the server should run in debug mode")
+def launch(config_path, host, port, debug):
+ app.config.update(config.read(config_path, DEFAULT_CONFIG))
+ app.run(host, port=int(port), debug=bool(debug))
- app.config.update(config.read(sys.argv[1], DEFAULT_CONFIG))
- host = sys.argv[2] if len(sys.argv) >= 3 else '0.0.0.0'
- port = int(sys.argv[3]) if len(sys.argv) >= 4 else 5000
- app.run(host, port=port, debug=True)
+if __name__ == '__main__':
+ launch()
diff --git a/swh/storage/objstorage/api/server.py b/swh/storage/objstorage/api/server.py
--- a/swh/storage/objstorage/api/server.py
+++ b/swh/storage/objstorage/api/server.py
@@ -3,6 +3,7 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
+import click
from flask import Flask, g, request
@@ -54,16 +55,19 @@
@app.route('/content/check', methods=['POST'])
def check():
- # TODO verify that an error on this content will be properly intercepted
- # by @app.errorhandler and the answer will be sent to client.
return encode_data(g.objstorage.check(**decode_request(request)))
-if __name__ == '__main__':
- import sys
+@click.command()
+@click.argument('Config-path', required=1)
+@click.option('--host', default='0.0.0.0', help="Host to run the server")
+@click.option('--port', default=5000, help="Server's port")
+@click.option('--debug/--nodebug', default=True,
+ help="Indicates if the server should run in debug mode")
+def launch(config_path, host, port, debug):
+ app.config.update(config.read(config_path, DEFAULT_CONFIG))
+ app.run(host, port=int(port), debug=bool(debug))
- app.config.update(config.read(sys.argv[1], DEFAULT_CONFIG))
- host = sys.argv[2] if len(sys.argv) >= 3 else '0.0.0.0'
- port = int(sys.argv[3]) if len(sys.argv) >= 4 else 5000
- app.run(host, port=port, debug=True)
+if __name__ == '__main__':
+ launch()

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 12:33 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220749

Event Timeline