-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.py
35 lines (32 loc) · 1.05 KB
/
debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import asyncio
import logging
from es2es import perform_task
if __name__ == "__main__":
logger = logging.getLogger("es2es")
logger.setLevel(os.environ.get('LOG_LEVEL', "DEBUG"))
handler = logging.StreamHandler()
handler.setFormatter(
logging.Formatter(
os.environ.get('LOG_FORMAT', "%(asctime)s [%(levelname)s] %(name)s: %(message)s")
)
)
config = {
"source_host": 'elasticsearch.local:8800',
"source_index": 'test-index',
"source_time_column":"created_time",
"source_greater_than_time":"",
"target_host": 'elasticsearch.local:8800',
"target_index": 'copy-index',
"time_interval": 2,
"data_limit": 100,
"request_timeout":100
}
logger.addHandler(handler)
try:
perform_task(logger=logger, config=config)
except Exception as e:
if logger:
logger.error("Error occured! {}".format(e))
finally:
logger.info("The es2es process has finished.")