-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
34 lines (27 loc) · 1.06 KB
/
Copy pathrun.py
File metadata and controls
34 lines (27 loc) · 1.06 KB
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
"""Run the Settled Slack app over Socket Mode (no public URL needed)."""
import logging
import time
from slack_bolt.adapter.socket_mode import SocketModeHandler
from settled import config
from settled.slack_app import build
logging.basicConfig(level=logging.INFO)
log = logging.getLogger("settled")
def main() -> None:
config.require_runtime() # fail fast with a clear message if misconfigured
app = build()
backoff = 2
while True: # supervisor: survive transient Socket Mode disconnects/crashes
try:
handler = SocketModeHandler(app, config.SLACK_APP_TOKEN)
print("⚡ Settled is running (Socket Mode). Ctrl-C to stop.")
handler.start()
return # clean exit
except KeyboardInterrupt:
print("Shutting down.")
return
except Exception as e: # noqa: BLE001
log.error("Socket Mode handler crashed: %s — reconnecting in %ss", e, backoff)
time.sleep(backoff)
backoff = min(backoff * 2, 60)
if __name__ == "__main__":
main()