123456789101112131415161718192021222324252627282930313233343536 |
- """Main application"""
- import time
- import sys
- from app import SCHEDULER, LOGGER, RESOURCE_NAMES, job_storage, jobs
- if __name__ == '__main__':
- # jobs.check_resources(RESOURCE_NAMES['gold'])
- # jobs.refill_resource(RESOURCE_NAMES['gold'])
- # sys.exit(0)
- JOBS = job_storage.get_jobs()
- for job in JOBS:
- LOGGER.info(
- 'Track resource "%s" at "%s"',
- job['resource_type'],
- job['minutes'],
- )
- SCHEDULER.add_job(
- jobs.check_resources,
- 'cron',
- args=[RESOURCE_NAMES[job['resource_type']]],
- id=job['resource_type'],
- replace_existing=True,
- minute=job['minutes']
- )
- try:
- while True:
- time.sleep(100)
- except KeyboardInterrupt:
- LOGGER.info('Exiting application')
- SCHEDULER.shutdown()
- sys.exit(0)
|