proxadmin/schedulerd.py
2017-03-08 20:53:09 +02:00

41 lines
1 KiB
Python

import schedule
import time
import subprocess, shlex
from manage import app, db
from app.models import Deployment
def job1_charge():
#process deployment charges
command_line = 'python3 manage.py charge_deployments'
args = shlex.split(command_line)
p = subprocess.Popen(args)
def job2_charge():
#process deployment charges
command_line = 'python3 manage.py charge_contracts'
args = shlex.split(command_line)
p = subprocess.Popen(args)
def job3_charge():
#process deployment charges
command_line = 'python3 manage.py charge_domains'
args = shlex.split(command_line)
p = subprocess.Popen(args)
if __name__ == '__main__':
schedule.every().day.at("12:30").do(job1_charge)
schedule.every().day.at("09:30").do(job2_charge)
schedule.every().day.at("16:30").do(job3_charge)
while True:
try:
#print('test')
schedule.run_pending()
except Exception as e:
print('scheduler error: {}'.format(str(e)))
break
time.sleep(1)