Page MenuHomeSoftware Heritage

D30.id93.diff
No OneTemporary

D30.id93.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
@@ -242,7 +242,8 @@
@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('--port', default=5000, type=click.INT,
+ help="Binding port of the server")
@click.option('--debug/--nodebug', default=True,
help="Indicates if the server should run in debug mode")
def launch(config_path, host, port, debug):
diff --git a/swh/storage/archiver/director.py b/swh/storage/archiver/director.py
--- a/swh/storage/archiver/director.py
+++ b/swh/storage/archiver/director.py
@@ -5,23 +5,23 @@
import swh
import logging
+import click
from datetime import datetime
-from swh.core import hashutil
+from swh.core import hashutil, config
from swh.scheduler.celery_backend.config import app
from . import tasks # NOQA
DEFAULT_CONFIG = {
- 'objstorage_path': '/tmp/swh-storage/objects',
- 'batch_max_size': 50,
- 'archival_max_age': 3600,
- 'retention_policy': 2,
- 'asynchronous': True,
-
- 'dbname': 'softwareheritage',
- 'user': 'root'
+ 'objstorage_path': ('str', '/tmp/swh-storage/objects'),
+ 'batch_max_size': ('int', 50),
+ 'archival_max_age': ('int', 3600),
+ 'retention_policy': ('int', 2),
+ 'asynchronous': ('bool', True),
+
+ 'dbconn': ('str', 'dbname=softwareheritage-dev user=guest')
}
task_name = 'swh.storage.archiver.tasks.SWHArchiverTask'
@@ -216,3 +216,29 @@
else:
raise ValueError("status must be either 'present', 'missing' "
"or 'ongoing'")
+
+
+@click.command()
+@click.argument('config-path', required=1)
+@click.option('--dbconn', default=DEFAULT_CONFIG['dbconn'][1],
+ help="Connection string for the database")
+@click.option('--async/--sync', default=DEFAULT_CONFIG['asynchronous'][1],
+ help="Indicates if the archiver should run asynchronously")
+def launch(config_path, dbconn, async):
+ # The configuration have following priority :
+ # command line > file config > default config
+ cl_config = {
+ 'dbconn': ('str', dbconn),
+ 'asynchronous': ('bool', async)
+ }
+ DEFAULT_CONFIG.update(cl_config)
+ conf = config.read(config_path, DEFAULT_CONFIG)
+ print(conf)
+ # Create connection data and run the archiver.
+ archiver = ArchiverDirector(conf['dbconn'], conf)
+ logger.info("Starting an archival at", datetime.now())
+ archiver.run()
+
+
+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
@@ -59,9 +59,10 @@
@click.command()
-@click.argument('Config-path', required=1)
+@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('--port', default=5000, type=click.INT,
+ help="Binding port of the server")
@click.option('--debug/--nodebug', default=True,
help="Indicates if the server should run in debug mode")
def launch(config_path, host, port, debug):

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 3:16 PM (5 d, 19 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3222250

Event Timeline