forked from flare-foundation/fsp-observer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (25 loc) · 806 Bytes
/
main.py
File metadata and controls
32 lines (25 loc) · 806 Bytes
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
import asyncio
import logging
import traceback
import dotenv
from configuration.config import get_config
from configuration.types import Configuration
from observer.message import Message, MessageLevel
from observer.observer import log_message, observer_loop
LOGGER = logging.getLogger()
def main(config: Configuration):
try:
asyncio.run(observer_loop(config))
except Exception as e:
mb = Message.builder().add(network=config.chain_id)
message = mb.build(
MessageLevel.CRITICAL,
(f"observer crashed (traceback in logs) - {e}"),
)
log_message(config, message)
LOGGER.exception(e)
LOGGER.error(traceback.format_exc())
if __name__ == "__main__":
dotenv.load_dotenv()
config = get_config()
main(config)