【发布时间】:2019-08-05 12:13:23
【问题描述】:
我将我的 scrapy 项目推送到 heroku。我需要自动化一些任务。因此,我从文档中了解了使用 Apsheduler 的自定义时钟。 这是我的目录结构:
.
├── bin
│ └── testargs.py
├── clock.py
├── Dockerfile
├── :hrsZp[do
├── newsfetch
│ ├── __init__.py
│ ├── items.py
│ ├── middlewares.py
│ ├── pipelines.py
│ ├── __pycache__
│ │ ├── __init__.cpython-34.pyc
│ │ ├── middlewares.cpython-34.pyc
│ │ ├── pipelines.cpython-34.pyc
│ │ └── settings.cpython-34.pyc
│ ├── settings.py
│ └── spiders
│ ├── indiatv.py
│ ├── __init__.py
│ ├── ndtv.py
│ ├── __pycache__
│ │ ├── indiatv.cpython-34.pyc
│ │ ├── __init__.cpython-34.pyc
│ │ ├── ndtv.cpython-34.pyc
│ │ ├── republic.cpython-34.pyc
│ │ ├── thehindu.cpython-34.pyc
│ │ └── zee.cpython-34.pyc
│ ├── republic.py
│ ├── thehindu.py
│ └── zee.py
├── p1.py
├── Procfile
├── requirements.txt
├── scrapy.cfg
└── setup.py
5 directories, 30 files
这是我的需求文件
Scrapy>=1.0.2
cffi>=1.12.2
psycopg2
APScheduler==3.0.0
这是我的clock.py文件
from apscheduler.schedulers.blocking import BlockingScheduler
sched = BlockingScheduler()
@sched.scheduled_job('interval', minutes=3)
def timed_job():
print('This job is run every three minutes.')
sched.start()
我没有收到任何消息(此作业每三分钟运行一次)在我的 heroku 日志中打印。我已提交所有更改并部署应用程序。请帮助运行我的脚本,以便我进一步自动化任务。
这是日志的当前状态:
2019-03-14T14:27:40.979762+00:00 heroku[clock.1]: State changed from crashed to starting
2019-03-14T14:27:47.752630+00:00 heroku[clock.1]: Starting process with command `: python clock.py`
2019-03-14T14:27:48.437785+00:00 heroku[clock.1]: State changed from starting to up
2019-03-14T14:27:50.480830+00:00 heroku[clock.1]: State changed from up to crashed
2019-03-14T14:27:50.466390+00:00 heroku[clock.1]: Process exited with status 0
【问题讨论】:
标签: python python-3.x heroku scrapy heroku-cli