Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

procfs needed by process component as of Piwik 2.2 #5041

Closed
peterbo opened this Issue · 11 comments

3 participants

Peter Boehlke Matthieu Aubry Anonymous Piwik user
Peter Boehlke
Collaborator

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.

Matthieu Aubry
Owner

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

Peter Boehlke
Collaborator

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

Peter Boehlke
Collaborator

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?

Matthieu Aubry
Owner

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.

Peter Boehlke
Collaborator

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 $?
Matthieu Aubry
Owner

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)

Peter Boehlke peterbo added this to the 2.3.0 - Piwik 2.3.0 milestone
Peter Boehlke peterbo self-assigned this
Matthieu Aubry
Owner

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

Philip Taffner sabl0r referenced this issue from a commit in sabl0r/piwik
Peter Boehlke peterbo Fixes #5041 - check if procfs is mounted c076fdb
Philip Taffner sabl0r referenced this issue from a commit in sabl0r/piwik
Matthieu Aubry 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
Something went wrong with that request. Please try again.