創建你的項目的根clock.py文件:
from apscheduler.schedulers.blocking import BlockingScheduler
import os
import sys
import logging
logging.basicConfig(stream=sys.stdout,level=logging.INFO)
logging.info('clock init')
sched = BlockingScheduler()
@sched.scheduled_job('interval', minutes=1)
def timed_job():
//logging.info('log message')
//use this if you want to run console command
os.system("php bin/console app:check-feedback")
//or
//whatever you want to run that every 1 minutes
sched.start()
你的項目的根目錄下創建文件requirements.txt:
APScheduler==3.0.0
加入這一行您的Procfile:
clock: python clock.py
運行此Heroku的命令
$heroku buildpacks:add --index 2 heroku/python
OR 在Heroku的儀表盤增加一個額外的蟒蛇buildpack你的測功機>應用程序>設置:
![enter image description here](https://i.stack.imgur.com/yvbJA.png)
部署您的應用程序。 最後,加測功機到您的時鐘進程:
$heroku ps:scale clock=1
檢查你的日誌:
$heroku logs --tail