-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
24 lines (23 loc) · 791 Bytes
/
run.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
import app
import time
import traceback
import socket
import os
if __name__ == "__main__":
exp_backoff = 0
while True:
try:
app.app = app.make_app(os.environ.get("JORRVASKR_CONFIG", "config.Config"))
# Import it just so it triggers.
# FIXME There should be a cleaner way to do this.
from app import filters
app.app.run(host=os.environ.get("JORRVASKR_HOST", "0.0.0.0"))
except (KeyboardInterrupt, SystemExit, socket.error):
print("Caught terminal signal")
raise
except Exception as e:
traceback.print_exc()
exp_backoff += 1
retry_gap = 3 ** exp_backoff
print("Retrying in %ss..." % retry_gap)
time.sleep(retry_gap)