configure logger.conf

configure cron for databases
This commit is contained in:
Wilson Gomez 2023-03-27 11:43:51 -05:00
parent ba79a4f022
commit 80300e08bd
2 changed files with 60 additions and 0 deletions

34
cron_databases.py Normal file
View File

@ -0,0 +1,34 @@
import os
import threading
import logging
from logging import config
databases = ["FERMAR", "PRESIKSAS"]
name_env = "tryton60"
daemon_path = os.path.expanduser('~/.virtualenvs/{}/bin/trytond-cron'.format(name_env))
name = "strytond_cron"
desc = "Tryton Cron"
config_path = os.path.expanduser('~/.trytond/trytond.conf')
logging_path = os.path.expanduser('~/.trytond/logger.conf')
options = "-c {}".format(config_path)
def thread_func(database_name):
db_name = str(database_name).lower()
log_options = "--logconf {}".format(logging_path)
pidfile = "/var/run/trytond_cron/{}_{}.pid".format(name, db_name)
os.system("{} -v {} -d {} --pidfile {} {}".format(daemon_path, options, database_name, pidfile, log_options))
threads = []
for database_name in databases:
t = threading.Thread(target=thread_func, args=[database_name])
threads.append(t)
for thread in threads:
thread.start()
for thread in threads:
thread.join()

26
logger.conf Normal file
View File

@ -0,0 +1,26 @@
[formatters]
keys=simple
[handlers]
keys=rotate,console
[loggers]
keys=root
[formatter_simple]
format=[%(asctime)s] %(levelname)s:%(name)s:%(message)s
datefmt=%a %b %d %H:%M:%S %Y
[handler_rotate]
class=handlers.TimedRotatingFileHandler
args=('/tmp/tryton.log', 'D', 1, 30)
formatter=simple
[handler_console]
class=StreamHandler
formatter=simple
args=(sys.stdout,)
[logger_root]
level=INFO
handlers=rotate,console