Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the update job to Synology DSM Task Scheduler #107

Closed
akaztp opened this issue Jun 23, 2014 · 4 comments

Comments

@akaztp
Copy link

commented Jun 23, 2014

Hi

I'm using PHPServerMon on an Synology DS212j. All went fine until I had to schedule the update job.
I wanted to use the DSM (synology desktop-like web interface) to schedule the update.
I've found that using the cli (though telnet) the status.cron.php worked ok but not when called using the DSM Task Scheduler. On the later case the script would output "This script can only be run from the command line.".
So I've removed the following lines from file status.cron.php:
if(!psm_is_cli()) {
die('This script can only be run from the command line.');
}

And now it works ok!
I have not tried to run the script using the cronjob configuration.

I don't know how to change the psdm_is_cli() to correctly accept the calling from the DSM Task Scheduler.
For me this solution is acceptable and I'm placing it here to help someone with the same problem.
Thx
ztp

@dopeh

This comment has been minimized.

Copy link
Member

commented Jun 23, 2014

Hi ztp,

Can you add the following to your config.php file, reload the page and let me know what it returns? The Synology DSM probably uses a different name.

var_dump($_SERVER['SERVER_SOFTWARE']);
var_dump(php_sapi_name());

Thanks.
Pep

@dopeh dopeh added the bug label Jun 23, 2014

@akaztp

This comment has been minimized.

Copy link
Author

commented Jun 24, 2014

Hi Pep, thank you for your interest on this.

Loading any page of the phpservemon on a browser, it outputs:
string(6) "Apache"
string(8) "fpm-fcgi"

But I've managed to see what these values are when "status.cron.php" is run under the Synology Diskstation Task Manager (and not under the browser call):

$_SERVER['SERVER_SOFTWARE'] is string(6) "Apache"
php_sapi_name() is string(3) "cli"
$_SERVER['argc'] is int(1)

So, the test in psm_is_cli():

return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)));

returns false because isset(...) returns true. Maybe that test on the 'SERVER_SOFTWARE' should be dropped?

Regards
ztp

@dopeh dopeh added this to the 3.1.0 milestone Jul 28, 2014

@dopeh dopeh self-assigned this Jul 28, 2014

dopeh pushed a commit that referenced this issue Jul 28, 2014
@dopeh

This comment has been minimized.

Copy link
Member

commented Jul 28, 2014

Fixed for next release.

@dopeh dopeh closed this Jul 28, 2014

@dopeh dopeh reopened this Jul 28, 2014

@dopeh

This comment has been minimized.

Copy link
Member

commented Jul 28, 2014

Update: removing the SERVER_SOFTWARE check will cause servers with "register_argc_argv" turned on to detect all web calls as CLI instead, so the previous "fix" is actually not a fix.

dopeh pushed a commit that referenced this issue Jul 28, 2014

@dopeh dopeh closed this Jul 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.