Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9342208
D26.id77.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D26.id77.diff
View Options
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
Details
Attached
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
Attached To
D26: Improve starting routines of storage & objstorage servers
Event Timeline
Log In to Comment