procfs needed by process component as of Piwik 2.2 #5041

Closed
peterbo opened this Issue Apr 25, 2014 · 11 comments

3 participants

@peterbo

As of Piwik 2.2, the locking mechanics of the new process component uses "ps -e" to check for a given PID.

Therefore, the process environment needs a mounted proc file system, which is not present on all servers.

So we should check for the presence of procfs.

@mattab
Piwik Open Source Analytics member

This may work: @is_resource(fopen('/proc', 'r'))

@peterbo

In c076fdb: Fixes #5041 - check if procfs is mounted

@peterbo

In 7631a79: Fixes #5041 - ditch negative semantic, that's more readable

@anonymous-piwik-user

I need to reopen this issue because this check is not sufficient and I think it is not requried.

The problem with the current solution is that it does not check if procfs is mounted. For example I have a shared hosting with no procfs:

$ mount
none on /proc type proc (rw)

A mounted /proc and not mounted /proc has both a "stream" resource type. So is_resource() is not sufficient enough to test if /proc is really mounted or not.
Create an empty folder somehwere and then compare

get_resource_type(@fopen('/proc', 'r')
get_resource_type(@fopen('/empty/folder', 'r')

See http://www.php.net/manual/en/resource.php

But there is an error anyway when ps is executed under such conditions

$ ps
Cannot find /proc/version - is /proc mounted?
$ echo $?
1

So the check returnsSuccessCode('ps') should already handle this situation. Or was there a case where this check was wrong?

@mattab
Piwik Open Source Analytics member

Or was there a case where this check was wrong?
yes, Peter added the new check after the 'ps' check was already in place, in commit above.

get_resource_type(@fopen('/proc', 'r')
get_resource_type(@fopen('/empty/folder', 'r')

What output do you get from these commands? maybe you know how we can patch the is_resource line?

@anonymous-piwik-user

What output do you get from these commands? maybe you know how we can patch the is_resource line?
both commands return a resource_type "stream" because fopen() always returns a stream or false. fopen() returns false if the folder /proc does not exist or you have no read permission for /proc.

Maybe it is possible to check if /proc/version or something like that exists and can be read? Would be interesting why the returnSuccessCode('ps') is true if /proc can not be accessed.

@peterbo

What is the response to the following command on your console?

ps > /dev/null 2>&1 & echo $?

@anonymous-piwik-user

I think that line is the problem. Why haven't I seen this before?

ps > /dev/null 2>&1 & echo $?

the single & brings ps to the background which is successfull and returns always 0. But the return value of ps itself is 1 in my case. But that is not checked with this command. This line should do the trick:

ps > /dev/null 2>&1; echo $?
@mattab
Piwik Open Source Analytics member

In 6b18957: fixes #5041 Fix typo. Kuddos @klauskw for the find!

@anonymous-piwik-user

For what it's worth, this continues to be a problem on FreeBSD.

RELEASE FreeBSD 8.2-RELEASE !#0

Sorry I don't have the technical chops to explain why. I have patched core/CliMulti/Process.php to always return false, and Piwik is working fine.

The error reported by Piwik whenever cron runs console core:archive:

ps: Process environment requires procfs(5)

@peterbo peterbo added this to the 2.3.0 - Piwik 2.3.0 milestone Jul 8, 2014
@peterbo peterbo self-assigned this Jul 8, 2014
@mattab
Piwik Open Source Analytics member

can you please create another ticket? we will investigate why it does not work yet on Freebsd

@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@peterbo peterbo Fixes #5041 - check if procfs is mounted c076fdb
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@peterbo peterbo Fixes #5041 - ditch negative semantic, that's more readable 7631a79
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab fixes #5041 Fix typo. Kuddos @klauskw for the find! 6b18957
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment