我用 PHP 开发了一个爬虫,它解析一个带有特定标头的 URL,并将所有内容的 URL 放入队列中。它工作正常。
我在 ubuntu 14.04 中开发了这段代码,并在 /etc/init 文件夹中放置了一个 .conf 文件,其中包含以下内容:
# Info
description "Warm the varnish to get the list of products"
author "Juanjo Aguilella"
# Events
start on startup
stop on shutdown
# Automatically respawn
respawn
respawn limit 100 5
# Run the script
# Note, in this example, if your PHP script return
# the string "ERROR", the daemon will stop itself.
script
[ $(exec /usr/bin/php -f /var/www/crawler.php) = 'ERROR' ] && ( stop; …
Run Code Online (Sandbox Code Playgroud)