-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapps.py
More file actions
29 lines (22 loc) · 853 Bytes
/
apps.py
File metadata and controls
29 lines (22 loc) · 853 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
import os
import sys
import threading
from django.apps import AppConfig
class SlackEventHandlerConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "slack_event_handler"
verbose_name = "Slack Event Handler"
def ready(self):
if "runserver" not in sys.argv:
return
# Runserver reloader: parent watches files, child runs the server. Only start the
# listener in the child so we don't open two Socket Mode connections to Slack.
if os.environ.get("RUN_MAIN") != "true":
return
def start_listener():
from slack_event_handler.runner import run_slack_event_handler
run_slack_event_handler()
t = threading.Thread(
target=start_listener, daemon=True, name="slack-event-handler"
)
t.start()