dantleech / fink

PHP Link Checker
MIT License
205 stars 26 forks source link

cli_set_process_title had an error #121

Open s22-tech opened 2 years ago

s22-tech commented 2 years ago

I keep getting the following message when running this script:

Warning: cli_set_process_title(): cli_set_process_title had an error: Not initialized correctly in /fink/bin/fink

It seems to run fine in spite of it, but I can't find how to get rid of it.

dantleech commented 2 years ago

Which platform is this (windows/mac/linux)?? Which PHP version?

jrlpreadspeaker commented 1 week ago

@dantleech Hello, I've got a similar error trying to use fink with cron.

/path_to_fink/fink https://www.site.com --output=/path_to_output/fink.json --max-external-distance=1 --exclude-url=/page/ --rate=2 --concurrency=2

Is my command, it gives an error near the one mentioned earlier when used with cron : ` X-Powered-By: PHP/8.2.23 Content-type: text/html; charset=UTF-8


Fatal error: Uncaught Error: Call to undefined function cli_set_process_title() in /home/xxx/vendor/dantleech/fink/bin/fink:25 Stack trace:

0 /home/xxx/vendor/bin/fink(119): include()

1 {main}

thrown in /home/xxx/vendor/dantleech/fink/bin/fink on line 25
`

Any idea why it trigger this error ?

Everything work fine when done from my terminal on the same server with the same command. Best regards

dantleech commented 1 week ago

Are you using windows? Happy to accept a pull request that would wrap the call with if (function_exists('cli_set_process_title')

jrlpreadspeaker commented 1 week ago

@dantleech Sure, I'll send a pull request. Currently running on Linux. https://www.php.net/manual/en/function.cli-set-process-title.php only available when using : CLI.

In cron it seems that PHP it used in "cgi-fcgi" (on my server)

jrlpreadspeaker commented 1 week ago

I've been able to fix the problem, I'm adding my solution so anyone who wants to turn it into cronjob knows. If you want to use in cron : /path_tofink/bin/fink yourargs

Might not work depeding on your PHP configuration.

What worked for me was : /usr/local/bin/php -q /path_tofink/bin/fink

Glad I found how to be sure I'm using the right PHP bin from this Stack Overflow help : https://stackoverflow.com/questions/19916949/running-php-from-cron-did-not-run-as-cli

-- Quote :

To fix this, first find the path to the correct php executable in a normal shell by typing this:

which php This should give you a path like /usr/bin/php. You can go one further and check if this is actually a "symbolic link" pointing at a different filename:

ls -l $(which php) (you'll see an arrow in the output if it is, like /usr/bin/php -> /usr/bin/php5-cli)