2022-04-04 16:34:51 +02:00
|
|
|
import os
|
2022-03-29 22:06:44 +02:00
|
|
|
import logging
|
|
|
|
import traceback
|
|
|
|
import argparse
|
|
|
|
from scribe.common import setup_logging
|
2022-05-05 20:07:39 +02:00
|
|
|
from scribe.elasticsearch.env import ElasticEnv
|
2022-03-29 22:06:44 +02:00
|
|
|
from scribe.elasticsearch.service import ElasticSyncService
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
prog='scribe-elastic-sync'
|
|
|
|
)
|
2022-05-05 20:07:39 +02:00
|
|
|
ElasticEnv.contribute_to_arg_parser(parser)
|
2022-03-29 22:06:44 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
try:
|
2022-05-05 20:07:39 +02:00
|
|
|
env = ElasticEnv.from_arg_parser(args)
|
2022-04-04 16:34:51 +02:00
|
|
|
setup_logging(os.path.join(env.db_dir, 'scribe-elastic-sync.log'))
|
|
|
|
server = ElasticSyncService(env)
|
2022-03-29 22:06:44 +02:00
|
|
|
server.run(args.reindex)
|
|
|
|
except Exception:
|
|
|
|
traceback.print_exc()
|
|
|
|
logging.critical('es sync terminated abnormally')
|
|
|
|
else:
|
|
|
|
logging.info('es sync terminated normally')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|