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