forked from chen310/NeteaseCloudMusicTasks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduler.py
More file actions
21 lines (20 loc) · 719 Bytes
/
scheduler.py
File metadata and controls
21 lines (20 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import random
from apscheduler.schedulers.background import BlockingScheduler
from index import start
if __name__ == "__main__":
try:
start()
scheduler_hour = os.environ.get(
"SCHEDULER_HOUR", random.randint(0, 23))
scheduler_minute = os.environ.get(
"SCHEDULER_MINUTE", random.randint(0, 59))
print("Scheduler hour: %s, minute: %s" %
(scheduler_hour, scheduler_minute))
scheduler = BlockingScheduler(timezone='Asia/Shanghai')
scheduler.add_job(start, 'cron', hour=scheduler_hour,
minute=scheduler_minute)
scheduler.start()
except Exception as e:
print(e)
exit(1)