Hi Andy,
Thanks a lot for the explanation! I'm going to have a look at the script.
Anyway, since I'm not able to know how the user started the server, it
seems that I have to combine ps and netstat (if netstat provides useful
information about the server, it may be interesting to inform the user).
Have a nice day
Vincent
Le 22/11/2018 à 12:58, Andy Seaborne a écrit :
Hi Vincent,
The script "./fuseki" runs Fuseki as an OS service, and it is a
wrapper around "java -jar fuseki-server.jar". It is the script that
records the process id and makes OS tools concerned with OS services
know about Fuseki. If you run the server directly then there isn't a
record of the running service.
To see if Fuseki is running via "java -jar" or "fuseki-server" then
you'll either have to look for the process or see if the port is
in-use with something like netstat.
Andy
On 22/11/2018 09:49, Vincent Ventresque wrote:
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