Hello,
I use Fuseki via command-line tools in a PHP project, so I made a small
'wrapper' to call ruby & sh scripts via php : it enables to send queries
and process the results without using a RDF library such as EasyRDF.
I'm currently writing a code for a "sandbox environment" based on the
php project. In this sandbox, the user should be able to install fuseki,
load sample data, run queries via a web page (php), and reuse RDF data
in a small mashup.
I tried to add a function to the wrapper so that the user can check
fuseki status (running? pid?), but it seems that `./fuseki status` only
works when fuseki has been started via the same script:
1) `./fuseki start` :
./fuseki status returns '[....] Fuseki is running with pid: 10373'
2) `./fuseki-server` or `java -jar fuseki-server.jar`
./fuseki status returns '[....] Fuseki is not running'
Therefore I tried to search for fuseki process via `ps aux`.
Could you tell me if this way is correct or if there's a better solution?
Here is the php code.
----------------------------------------------------
public function fusekiStatus() {
//----- search fuseki process ----------------
$cmd = "ps aux|grep fuseki";
$process = popen($cmd, "r");
$psOutput = stream_get_contents($process);
pclose($process);
//----- analyze ps output ----------------------
if (preg_match("/java/", $psOutput) == 1) {
$status = ['running' => TRUE];
$msg = "Processus Fuseki ok ('running').";
}
else {
$status = ['running' => FALSE];
$msg = "ATTENTION, aucun processus Fuseki trouvé ('not
running'?).";
}
$status['msg'] = $msg . "<br>`ps aux|grep fuseki` donne
`$psOutput`<br>";
return $status;
}
----------------------------------------------------
Thanks in advance
Vincent
--