8. Set up a cron job or scheduled task to run the worker once every 5-10
minutes to pick up the recent "public" postings of your friends. Example:
- cd /base/directory; /path/to/php scripts/worker.php
+ cd /base/directory; /path/to/php bin/worker.php
Change "/base/directory", and "/path/to/php" as appropriate for your situation.
If you are using a Linux server, run "crontab -e" and add a line like the
one shown, substituting for your unique paths and settings:
-*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php scripts/worker.php
+*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php bin/worker.php
You can generally find the location of PHP by executing "which php". If you
have troubles with this section please contact your hosting provider for
*/10 * * * * cd /var/www/friendica/friendica/ && sudo -u www-data /usr/bin/php
-d suhosin.executor.func.blacklist=none -d suhosin.executor.eval.blacklist=none
--f scripts/worker.php
+-f bin/worker.php
This worked well for simple test cases, but the friendica-cron still failed with
a fatal error:
suhosin[22962]: ALERT - function within blacklist called: proc_open() (attacker
'REMOTE_ADDR not set', file '/var/www/friendica/friendica/boot.php', line 1341)
-After a while I noticed, that scripts/worker.php calls further php script via
+After a while I noticed, that bin/worker.php calls further php script via
proc_open. These scripts themselves also use proc_open and fail, because they
are NOT called with -d suhosin.executor.func.blacklist=none.
set_time_limit(0);
// Call the worker
- $cmdline = $php.' scripts/worker.php';
+ $cmdline = $php.' bin/worker.php';
$executed = false;
--- /dev/null
+#!/usr/bin/env php
+<?php
+/**
+ * @file bin/worker.php
+ * @brief Starts the background processing
+ */
+
+use Friendica\App;
+use Friendica\BaseObject;
+use Friendica\Core\Addon;
+use Friendica\Core\Config;
+use Friendica\Core\Worker;
+
+// Ensure that worker.php is executed from the base path of the installation
+if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
+ $directory = dirname($_SERVER["argv"][0]);
+
+ if (substr($directory, 0, 1) != "/") {
+ $directory = $_SERVER["PWD"]."/".$directory;
+ }
+ $directory = realpath($directory."/..");
+
+ chdir($directory);
+}
+
+require_once "boot.php";
+require_once "include/dba.php";
+
+$a = new App(dirname(__DIR__));
+BaseObject::setApp($a);
+
+require_once ".htconfig.php";
+dba::connect($db_host, $db_user, $db_pass, $db_data);
+unset($db_host, $db_user, $db_pass, $db_data);
+
+Config::load();
+
+// Check the database structure and possibly fixes it
+check_db(true);
+
+// Quit when in maintenance
+if (Config::get('system', 'maintenance', true)) {
+ return;
+}
+
+$a->set_baseurl(Config::get('system', 'url'));
+
+Addon::loadHooks();
+
+$spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn"));
+
+if ($spawn) {
+ Worker::spawnWorker();
+ killme();
+}
+
+$run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
+
+Worker::processQueue($run_cron);
+
+Worker::unclaimProcess();
+
+Worker::endProcess();
+
+killme();
+
Set up a cron job or scheduled task to run the worker once every 5-10 minutes in order to perform background processing.
Example:
- cd /base/directory; /path/to/php scripts/worker.php
+ cd /base/directory; /path/to/php bin/worker.php
Change "/base/directory", and "/path/to/php" as appropriate for your situation.
If you are using a Linux server, run "crontab -e" and add a line like the
one shown, substituting for your unique paths and settings:
- */10 * * * * cd /home/myname/mywebsite; /usr/bin/php scripts/worker.php
+ */10 * * * * cd /home/myname/mywebsite; /usr/bin/php bin/worker.php
You can generally find the location of PHP by executing "which php".
If you run into trouble with this section please contact your hosting provider for assistance.
7. Erstelle einen Cron job oder einen regelmäßigen Task, um den Poller alle 5-10 Minuten im Hintergrund ablaufen zu lassen. Beispiel:
- `cd /base/directory; /path/to/php scripts/worker.php`
+ `cd /base/directory; /path/to/php bin/worker.php`
Ändere "/base/directory" und "/path/to/php" auf deine Systemvorgaben.
Wenn du einen Linux-Server nutzt, benutze den Befehl "crontab -e" und ergänze eine Zeile wie die Folgende; angepasst an dein System
-`*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php scripts/worker.php`
+`*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php bin/worker.php`
Du kannst den PHP-Pfad finden, indem du den Befehl „which php“ ausführst.
Wenn du Schwierigkeiten mit diesem Schritt hast, kannst du deinen Hosting-Anbieter kontaktieren.
+++ /dev/null
-#!/usr/bin/env php
-<?php
-/**
- * @file scripts/worker.php
- * @brief Starts the background processing
- */
-
-use Friendica\App;
-use Friendica\BaseObject;
-use Friendica\Core\Addon;
-use Friendica\Core\Config;
-use Friendica\Core\Worker;
-
-// Ensure that worker.php is executed from the base path of the installation
-if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
- $directory = dirname($_SERVER["argv"][0]);
-
- if (substr($directory, 0, 1) != "/") {
- $directory = $_SERVER["PWD"]."/".$directory;
- }
- $directory = realpath($directory."/..");
-
- chdir($directory);
-}
-
-require_once "boot.php";
-require_once "include/dba.php";
-
-$a = new App(dirname(__DIR__));
-BaseObject::setApp($a);
-
-require_once ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
-Config::load();
-
-// Check the database structure and possibly fixes it
-check_db(true);
-
-// Quit when in maintenance
-if (Config::get('system', 'maintenance', true)) {
- return;
-}
-
-$a->set_baseurl(Config::get('system', 'url'));
-
-Addon::loadHooks();
-
-$spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn"));
-
-if ($spawn) {
- Worker::spawnWorker();
- killme();
-}
-
-$run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
-
-Worker::processQueue($run_cron);
-
-Worker::unclaimProcess();
-
-Worker::endProcess();
-
-killme();
-
*/
public static function spawnWorker()
{
- $args = ["scripts/worker.php", "no_cron"];
+ $args = ["bin/worker.php", "no_cron"];
get_app()->proc_run($args);
}
$MYSQL -uroot -proot friendica < /vagrant/friendica_test_data.sql
# create cronjob - activate if you have enough memory in you dev VM
-echo "*/10 * * * * cd /vagrant; /usr/bin/php scripts/worker.php" >> friendicacron
+echo "*/10 * * * * cd /vagrant; /usr/bin/php bin/worker.php" >> friendicacron
sudo crontab friendicacron
sudo rm friendicacron