]> git.wh0rd.org - tt-rss.git/blame - update_feeds.php
daemon2: check proper lockfile location in reap_children()
[tt-rss.git] / update_feeds.php
CommitLineData
cd2cd415 1#!/usr/bin/php
1d3a17c7 2<?php
aa8ab7ae 3 define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
de696427
AD
4 define('DISABLE_SESSIONS', true);
5
aa8ab7ae
AD
6 error_reporting(DEFAULT_ERROR_LEVEL);
7
1f2b01ed
AD
8 require_once "sanity_check.php";
9 require_once "config.php";
10 require_once "db.php";
11 require_once "db-prefs.php";
12 require_once "functions.php";
31a6d42d
AD
13
14 $lock_filename = "update_feeds.lock";
15
16 $lock_handle = make_lockfile($lock_filename);
17
45004d43 18 // Try to lock a file in order to avoid concurrent update.
31a6d42d
AD
19 if (!$lock_handle) {
20 die("error: Can't create lockfile ($lock_filename). ".
21 "Maybe another process is already running.\n");
22 }
1f2b01ed 23
45004d43 24 // Create a database connection.
1f2b01ed
AD
25 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
26
27 if (!$link) {
28 if (DB_TYPE == "mysql") {
29 print mysql_error();
30 }
31 // PG seems to display its own errors just fine by default.
32 return;
33 }
34
f29ba148 35 init_connection($link);
1f2b01ed 36
45004d43 37 // Update all feeds needing a update.
d2bf48f9 38 update_daemon_common($link);
1f2b01ed
AD
39
40 db_close($link);
41
cfa43e02 42 unlink(LOCK_DIRECTORY . "/$lock_filename");
1f2b01ed 43?>