fixes
parent
4becf0c73c
commit
a6e174ccf6
17
model.sql
17
model.sql
|
@ -1,7 +1,6 @@
|
||||||
begin;
|
begin;
|
||||||
DROP TABLE correos.destinatarios;
|
DROP TABLE correos.destinatarios;
|
||||||
DROP TABLE correos.cartas;
|
DROP TABLE correos.cartas;
|
||||||
--DROP TABLE correos.origenes;
|
|
||||||
DROP TABLE correos.direcciones;
|
DROP TABLE correos.direcciones;
|
||||||
DROP TABLE correos.mxrecords;
|
DROP TABLE correos.mxrecords;
|
||||||
DROP TABLE correos.arecords;
|
DROP TABLE correos.arecords;
|
||||||
|
@ -9,8 +8,6 @@ DROP TABLE correos.ipv4addrs;
|
||||||
DROP TABLE correos.fqdns;
|
DROP TABLE correos.fqdns;
|
||||||
|
|
||||||
DROP SCHEMA correos;
|
DROP SCHEMA correos;
|
||||||
|
|
||||||
|
|
||||||
CREATE SCHEMA correos;
|
CREATE SCHEMA correos;
|
||||||
|
|
||||||
CREATE TABLE correos.fqdns (
|
CREATE TABLE correos.fqdns (
|
||||||
|
@ -34,7 +31,7 @@ CREATE TABLE correos.direcciones (
|
||||||
nombre VARCHAR,
|
nombre VARCHAR,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
UNIQUE (direccion),
|
UNIQUE (direccion),
|
||||||
FOREIGN KEY(dominioid) REFERENCES correos.fqdns (id)
|
FOREIGN KEY(dominioid) REFERENCES correos.fqdns (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE correos.mxrecords (
|
CREATE TABLE correos.mxrecords (
|
||||||
|
@ -44,7 +41,7 @@ CREATE TABLE correos.mxrecords (
|
||||||
prioridad INTEGER DEFAULT 10000,
|
prioridad INTEGER DEFAULT 10000,
|
||||||
validohasta INTEGER DEFAULT 0,
|
validohasta INTEGER DEFAULT 0,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
FOREIGN KEY(fqdnid) REFERENCES correos.fqdns (id)
|
FOREIGN KEY(fqdnid) REFERENCES correos.fqdns (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE correos.arecords (
|
CREATE TABLE correos.arecords (
|
||||||
|
@ -57,8 +54,8 @@ CREATE TABLE correos.arecords (
|
||||||
sesiones INTEGER DEFAULT 0,
|
sesiones INTEGER DEFAULT 0,
|
||||||
validohasta INTEGER DEFAULT 0,
|
validohasta INTEGER DEFAULT 0,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
FOREIGN KEY(fqdnid) REFERENCES correos.fqdns (id),
|
FOREIGN KEY(fqdnid) REFERENCES correos.fqdns (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
FOREIGN KEY(ipv4id) REFERENCES correos.ipv4addrs (id)
|
FOREIGN KEY(ipv4id) REFERENCES correos.ipv4addrs (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE correos.cartas (
|
CREATE TABLE correos.cartas (
|
||||||
|
@ -67,7 +64,7 @@ CREATE TABLE correos.cartas (
|
||||||
contenido TEXT,
|
contenido TEXT,
|
||||||
recibido TIMESTAMP WITH TIME ZONE,
|
recibido TIMESTAMP WITH TIME ZONE,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
FOREIGN KEY(remitenteid) REFERENCES correos.direcciones (id)
|
FOREIGN KEY(remitenteid) REFERENCES correos.direcciones (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE correos.destinatarios (
|
CREATE TABLE correos.destinatarios (
|
||||||
|
@ -78,7 +75,7 @@ CREATE TABLE correos.destinatarios (
|
||||||
intentos INTEGER DEFAULT 0,
|
intentos INTEGER DEFAULT 0,
|
||||||
timestamp TIMESTAMP WITH TIME ZONE,
|
timestamp TIMESTAMP WITH TIME ZONE,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
FOREIGN KEY(direccionid) REFERENCES correos.direcciones (id),
|
FOREIGN KEY(direccionid) REFERENCES correos.direcciones (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
FOREIGN KEY(cartaid) REFERENCES correos.cartas (id)
|
FOREIGN KEY(cartaid) REFERENCES correos.cartas (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
commit;
|
commit;
|
|
@ -4,18 +4,23 @@ import time
|
||||||
import signal
|
import signal
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
if not os.environ.get('HEARTBEAT'):
|
||||||
|
hb = 60 * 15 # 15 minutos
|
||||||
|
else:
|
||||||
|
hb = int(os.environ.get('HEARTBEAT'))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
async def main_loop():
|
async def main_loop():
|
||||||
await log.info('Demonio iniciado')
|
await log.info('Demonio iniciado')
|
||||||
doki = int(time.time()) + 60
|
doki = int(time.time()) + hb
|
||||||
while True:
|
while True:
|
||||||
if await pre_process():
|
if await pre_process():
|
||||||
await enviaCorreos()
|
await enviaCorreos()
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
i = int(time.time())
|
i = int(time.time())
|
||||||
if i >= doki:
|
if i >= doki:
|
||||||
doki = i + 60
|
doki = i + hb
|
||||||
await log.info('Heartbeat')
|
await log.info('Heartbeat')
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
10
server.py
10
server.py
|
@ -4,18 +4,24 @@ import time
|
||||||
import signal
|
import signal
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
|
if not os.environ.get('HEARTBEAT'):
|
||||||
|
hb = 60 * 15 # 15 minutos
|
||||||
|
else:
|
||||||
|
hb = int(os.environ.get('HEARTBEAT'))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
mayordomo = create_async_smtp_server()
|
mayordomo = create_async_smtp_server()
|
||||||
|
|
||||||
async def main_loop():
|
async def main_loop():
|
||||||
await log.info('Demonio iniciado')
|
await log.info('Demonio iniciado')
|
||||||
doki=int(time.time()) + 60
|
doki=int(time.time()) + hb
|
||||||
while True:
|
while True:
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
i = int(time.time())
|
i = int(time.time())
|
||||||
if i >= doki:
|
if i >= doki:
|
||||||
doki = i + 60
|
doki = i + hb
|
||||||
await log.info('Heartbeat')
|
await log.info('Heartbeat')
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
Loading…
Reference in New Issue