Blame view

src/alert_manager/start_agent_alert_manager.py 730 Bytes
b4e8963c   Etienne Pallier   Each agent (envmo...
1
2
3
4
5
#!/usr/bin/env python3

import os
import sys

b2e9866d   Etienne Pallier   bugfix start_agen...
6
7
8
# To avoid a "ModuleNotFoundError: No module named 'dashboard'"... (not even 1 app found) :
sys.path.insert(0, os.path.abspath(".."))
# To avoid a "ModuleNotFoundError: No module named 'src'"
b4e8963c   Etienne Pallier   Each agent (envmo...
9
sys.path.append('..')
b2e9866d   Etienne Pallier   bugfix start_agen...
10
11
12
print("Starting with this sys.path", sys.path)

# DJANGO setup
b4e8963c   Etienne Pallier   Each agent (envmo...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Go into src/
os.chdir('..')
#print("Current directory : " + str(os.getcwd()))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "src.pyros.settings")
#os.environ['SECRET_KEY'] = 'abc'
#os.environ['ENVIRONMENT'] = 'production'
import django
django.setup()

# MONITORING AGENT setup
agent="alert_manager"

if agent=="alert_manager":
    from alert_manager.tasks import AlertListener
    AlertListener().run()