Commit 60f5c447 authored by Stephan Feurer's avatar Stephan Feurer
Browse files

Merge branch 'dev' of git.vshn.net:elia.ponzio/generic-monitoring into dev

parents d5fd416c 50d5e08e
......@@ -29,7 +29,7 @@ A ORM will help us, TBD.
* create database: `CREATE DATABASE cynomys;`
* grant user access to db: `GRANT ALL ON cynomys TO cynomys;`
Use cockroachdb as django backend: `DJANGO_DATABASE='cockroach-insecure' ./manage.py xxx`
Use cockroachdb as django backend: `CYNOMYS_DATABASE='cockroach-insecure' ./manage.py xxx`
## Install
......@@ -50,6 +50,7 @@ deactivate
## Run
```
export CYNOMYS_EMAIL_PASSWORD=<SUPER_SECRET>
./manage.py migrate
./manage.py createsuperuser
./manage.py runserver
......
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ('celery_app',)
from celery import shared_task
from django_celery_beat.models import PeriodicTask
import subprocess
@shared_task
def ping(host, timeout, **kwargs):
response = subprocess.run(["ping", "-c", "1", "-w", timeout, host])
print("ping from " + host + " with return value: " + str(response.returncode))
parent_task = PeriodicTask.objects.get(id=kwargs['task_id'])
print("the parent task: " + parent_task.name)
if response.returncode:
pass
def helloworld():
print("Oh Hai world! ")
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ('celery_app',)
......@@ -8,7 +8,7 @@ import subprocess
# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app = Celery('cynomys')
app = Celery('project')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
......@@ -17,7 +17,7 @@ app = Celery('cynomys')
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django apps.
app.autodiscover_tasks()
app.autodiscover_tasks(['cynomys.tasks',])
@app.task(bind=True)
......@@ -29,15 +29,6 @@ def debug_task(self):
def helloworld():
print("Oh Hai world!")
@app.task()
def ping(host, timeout):
response = subprocess.run(["ping", "-c", "1", "-w", timeout, host])
print("ping from " + host + " with return value: " + str(response.returncode))
if response.returncode:
pass
@app.task()
def http_check():
......
......@@ -100,7 +100,7 @@ DATABASES = {
}
}
default_database = environ.get('DJANGO_DATABASE', 'sqlite')
default_database = environ.get('CYNOMYS_DATABASE', 'sqlite')
DATABASES['default'] = DATABASES[default_database]
# Password validation
......@@ -156,9 +156,11 @@ CELERY_RESULT_BACKEND = "redis://127.0.0.1:6379/0"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = "cynomys.vshn@gmail.com"
EMAIL_HOST_PASSWORD = "4PQtEPsLSKstjTFKD29LeScowxsFxS8n"
EMAIL_HOST_PASSWORD = environ.get('CYNOMYS_EMAIL_PASSWORD', 'sqlite')
EMAIL_PORT = 587
EMAIL_SUBJECT_PREFIX = "[cynomys] "
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = "4PQtEPsLSKstjTFKD29LeScowxsFxS8n"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment