From: Hypolite Petovan Date: Mon, 19 Mar 2018 03:25:21 +0000 (-0400) Subject: Move scripts/worker.php to bin/ X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1c2deac7e5db2da90e798e7860368d328f5e52d8;p=friendica.git Move scripts/worker.php to bin/ --- diff --git a/INSTALL.txt b/INSTALL.txt index ee3779bc9d..2a95822a2e 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -113,14 +113,14 @@ tables, so that you can start fresh. 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 @@ -293,14 +293,14 @@ cron by using something like */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. diff --git a/bin/daemon.php b/bin/daemon.php index b53a69e1b9..6b0e377a3a 100644 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -104,7 +104,7 @@ while (true) { set_time_limit(0); // Call the worker - $cmdline = $php.' scripts/worker.php'; + $cmdline = $php.' bin/worker.php'; $executed = false; diff --git a/bin/worker.php b/bin/worker.php new file mode 100644 index 0000000000..67f9fed1a5 --- /dev/null +++ b/bin/worker.php @@ -0,0 +1,66 @@ +#!/usr/bin/env php +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(); + diff --git a/doc/Install.md b/doc/Install.md index 23232347ed..4c37ed76d1 100644 --- a/doc/Install.md +++ b/doc/Install.md @@ -101,14 +101,14 @@ You might wish to move/rename .htconfig.php to another name and empty (called 'd 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. diff --git a/doc/de/Install.md b/doc/de/Install.md index 916c131d61..c718804174 100644 --- a/doc/de/Install.md +++ b/doc/de/Install.md @@ -86,13 +86,13 @@ Wenn du irgendwelche **kritischen** Fehler zu diesen Zeitpunkt erhalten solltest 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. diff --git a/scripts/worker.php b/scripts/worker.php deleted file mode 100755 index 1980a21b15..0000000000 --- a/scripts/worker.php +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env php -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(); - diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 525287dd0d..9d5b75f45c 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -1003,7 +1003,7 @@ class Worker */ public static function spawnWorker() { - $args = ["scripts/worker.php", "no_cron"]; + $args = ["bin/worker.php", "no_cron"]; get_app()->proc_run($args); } diff --git a/util/vagrant_provision.sh b/util/vagrant_provision.sh index 7ca5a1f4e3..eab125b0d8 100755 --- a/util/vagrant_provision.sh +++ b/util/vagrant_provision.sh @@ -88,7 +88,7 @@ echo "create database friendica DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_ge $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