【问题标题】:Start Scrapyd as service启动 Scrapyd 作为服务
【发布时间】:2016-03-10 11:35:22
【问题描述】:
  1. 我想将scrapyd作为服务启动,但是当我启动scrapyd时, 如果我关闭 SSH 会话,服务 scrapyd 会自动关闭。

  2. 当我尝试像这样作为服务启动时出现错误:

    root@vps:~# service scrapyd start
    scrapyd: Failed to start scrapyd.service: Unit scrapyd.service failed to load: No such file or directory.
    
  3. 当我尝试启动 daemon scrapyd 时,CURL 请求返​​回:

    {"status": "error", "message": "Use \"scrapy\" to see available commands", "node_name": "vps"}
    

有人可以帮我启动我的scrapyd作为服务吗!

【问题讨论】:

标签: web-scraping scrapy scrapy-spider scrapyd


【解决方案1】:
daemon --chdir=/home/Crawler scrapyd

我需要设置 --chdir 来加载 Scrapy 文件夹中的服务!

【讨论】:

    【解决方案2】:

    我无法通过 /etc/rc.localcrontab 启动我的 scrapyd,所以我找到了解决方法。我相信会有更好的方法,但同时这对我有用。

    我创建了一个python文件start.py

    import os
    
    os.system('/usr/bin/python3 /home/ubuntu/.local/bin/scrapyd > /home/ubuntu/scrapy.log &')
    

    并且只需通过 crontab 调用 python 文件start.py

    通过cronat -e将此添加到 crintab 文件中。

    @reboot /usr/bin/python3 /home/ubuntu/start.py
    

    基本上我所做的就是通过 crontab 调用 python filr 通过 shell 执行 scrapy。

    如果有人发现更好的东西,请发表评论。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-10
      • 1970-01-01
      • 2018-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多