You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Ian Emmons <ia...@emmons.mobi> on 2014/03/14 10:40:26 UTC

Running Fuseki as a Daemon or Windows Service

I see a number of oblique references online to running Fuseki as a *nix daemon.  However, I see no clear procedure for doing so.  Is such documentation written anywhere?

Also, and equally important to my customers, is there a way to run Fuseki as a Windows Service?

Thanks,

Ian

Re: Trying to create a Jena Fuseki Windows Service installer

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@public.gmane.org>:
>>>>> Andy Seaborne <an...@public.gmane.org>:
>> I'm wondering why you need to write a java driver.

> Not something I _need_ to do, just something I would like to try out.

> I stumbled over this maven plugin
>   https://github.com/alexkasko/windows-service-installer
> and thought "hey, an MSI that would install jena fuseki as a windows
> service, that would be kind of cool".

Well, I won't get an msi... running
 mvn windows-service-installer:installer
on https://github.com/steinarb/fusekiservice currently gets me this, in
the target directory:
  -rw-rw-rw-  1 sb None 92126065 02-07 09:06 fusekiservice-0.0.1-SNAPSHOT-installer.zip
  -rw-rw-rw-  1 sb None 24859992 02-07 09:06 install.jar

Double-clicking on the "install.jar" starts an IzPack installer of the
stuff in the zip file (which in its the current state doesn't include
the unpacked jena fuseki webapp, so the it won't actually run).

(Note: I haven't actually run the installer fully through yet. I think I
will use a VM for that, at least for the first couple of runs)

Re: Trying to create a Jena Fuseki Windows Service installer

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Andy Seaborne <an...@public.gmane.org>:

> I'm wondering why you need to write a java driver.

Not something I _need_ to do, just something I would like to try out.

I stumbled over this maven plugin
  https://github.com/alexkasko/windows-service-installer
and thought "hey, an MSI that would install jena fuseki as a windows
service, that would be kind of cool".

> Is there something that the standalone server command line won't do
> for you?  You can give a whole Jetty config file but "--port=4000"
> seems to do what you want.

An msi would give an easier installation procedure for windows
sysadmins.  Fewer parts in motion that can go wrong.

Re: Trying to create a Jena Fuseki Windows Service installer (Was: Running Fuseki as a Daemon or Windows Service)

Posted by Andy Seaborne <an...@apache.org>.
Hi Steinar,

I'm wondering why you need to write a java driver.

Is there something that the standalone server command line won't do for 
you?  You can give a whole Jetty config file but "--port=4000" seems to 
do what you want.

A cmd script to run a service then makes running your setup easy - it's 
a common way to setup services on Windows (and Linux).

Or run the WAR in Tomcat because running tomcat as a service on windows 
is well documented with lots of help on StackOverflow and elsewhere.

Or repackage a custom setup in a WAR file (that's what they are for 
after all).


Fuseki needs to find the content for the UI. In standalone server form, 
the webpages are outside the jar and the code needs to find them.  In 
war file form, the web pages are in the war file. In a war file, 
FUSEKI_HOME is not needed - createWebApp isn't called.

If FUSEKI_HOME is null, then it looks in "webapp" and "src/main/webapp" 
(more for develoopment mode) but setting environment variable 
FUSEKI_HOME is better.

	Andy

(who does not run Fuseki as a Windows service)

On 31/01/16 18:18, Steinar Bang wrote:
> Hi,
>
> I am trying to use the windows-service-installer maven plugin to create
> a windows installer that will install a windows service that will run
> Jena Fuseki.
>   https://github.com/alexkasko/windows-service-installer
>
> My DaemonLauncher for Jena Fuseki, is here:
>   https://github.com/steinarb/fusekiservice/blob/master/src/main/java/no/priv/bang/fuseki/fusekiservice/FusekiService.java
>
> I have written a JUnit test that attempts to start and stop the service
> (just to see if I can make it run at all).
>   https://github.com/steinarb/fusekiservice/blob/master/src/test/java/no/priv/bang/fuseki/fusekiservice/FusekiServiceTest.java
>
> The JUnit test currently fails with the following console output:
>   [2016-01-31 18:21:38] FusekiService INFO  FUSEKI_HOME: null
>   [2016-01-31 18:21:38] Server     ERROR Can't find resourceBase (tried webapp and src/main/webapp)
>   [2016-01-31 18:21:38] Server     ERROR Failed to start
>
> So my question is: what am I missing from the FusekiService.startDaemon() method?
>
> I have been stealing code from here (mainly):
>   https://github.com/apache/jena/blob/master/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
>
> The reason I haven tried using FusekiCmd, is that I would like to have
>          JettyFuseki.instance.start();
> in the startDaemon() method, and
>          JettyFuseki.instance.join();
> in the stopDaemon() method (unless I've misunderstood how they are
> supposed to work...?)
>
> The failing code, is in
>   https://github.com/apache/jena/blob/master/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
> in the JettyFuseki.createWebApp() method.
>
> The code in createWebapp() looks like it expects a directory, with
> WEB-INF/web.xml residing in that directory (ie. WEB-INF a subdirectly of
> the webapp directory), so I have been toying with the idea of
> downloading and unpacking the fuseki webapp in a directory and give that
> directory.
>
> But even if I could make that work in a JUnit test, I have no idea of
> how to accomplish the same thing in a windows service installed by an
> installer created by the windows-service-installer maven plugin...
>
> And the ready packaged jena fuseki starts and runs from a single .jar,
> so unpacking something shouldn't be necessary.
>
> So how should I proceed with this?  Is this doable?
>
> Thanks!
>
>
> - Steinar
>


Re: Trying to create a Jena Fuseki Windows Service installer

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@public.gmane.org>:

> Even more progress.  With the current state of
> https://github.com/steinarb/fusekiservice the installer installs, and
> starts a service, running Jena Fuseki, that listens to port 4000.

I've switched the port back to the default 3030, but it is easily
modified in the jenafusekiservice.properties file.

> I haven't actually tried using it... for one thing, I don't presently
> know where TDB will put its database... but Jena Fuseki starts and runs,
> and that's definitely progress.

The current version installs in
 C:\Program Files\Apache\Jena\Fuseki
and the Fuseki data directory will be
 C:\Program Files\Apache\Jena\Fuseki\run
with the TDB databases placed in
 C:\Program Files\Apache\Jena\Fuseki\run\databases

The value of the "run" directory can be modified by setting the
jena.fuseki.datalocation property in the jenafusekiservice.properties
file:
 https://github.com/steinarb/fusekiservice/blob/master/src/main/resources/jenafusekiservice.properties

> Stop and Start works from the Windows Services window.

> Instructions for running the installer and uninstall can be found in the
> README file of https://github.com/steinarb/fusekiservice

 https://github.com/steinarb/fusekiservice/blob/master/README.org

> The uninstaller will stop the service, and uninstall it.

This still is valid.

Re: Trying to create a Jena Fuseki Windows Service installer

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@public.gmane.org>:

> Progress!

Even more progress.  With the current state of
https://github.com/steinarb/fusekiservice the installer installs, and
starts a service, running Jena Fuseki, that listens to port 4000.

I haven't actually tried using it... for one thing, I don't presently
know where TDB will put its database... but Jena Fuseki starts and runs,
and that's definitely progress.

Stop and Start works from the Windows Services window.

Instructions for running the installer and uninstall can be found in the
README file of https://github.com/steinarb/fusekiservice

The uninstaller will stop the service, and uninstall it.

Re: Trying to create a Jena Fuseki Windows Service installer

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@public.gmane.org>:

> The reason I haven tried using FusekiCmd, is that I would like to have
>         JettyFuseki.instance.start();
> in the startDaemon() method, and
>         JettyFuseki.instance.join();
> in the stopDaemon() method (unless I've misunderstood how they are
> supposed to work...?)

> The failing code, is in
>  https://github.com/apache/jena/blob/master/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
> in the JettyFuseki.createWebApp() method.

> The code in createWebapp() looks like it expects a directory, with
> WEB-INF/web.xml residing in that directory (ie. WEB-INF a subdirectly of
> the webapp directory), so I have been toying with the idea of
> downloading and unpacking the fuseki webapp in a directory and give that
> directory.

Progress!

Now the webapp starts in the unit test.  

Unfortunately, it doesn't stop yet.  This means that calling
 JettyFuseki.instance.join()
like I do in FusekiService.stopDaemon() was not the way to stop the
server... I have to read a bit more code, I guess...?

What I did was to unpack the jena fuseki webapp where the unit test
would find it ("./webapp" from the CWD of the unit test):
 https://github.com/steinarb/fusekiservice/commit/87dbb7be634a0b26137854798eaeaef7074ba5cf

I get the following on the console:
[2016-02-06 12:17:45] FusekiService INFO  FUSEKI_HOME: null
[2016-02-06 12:17:46] Server     INFO  Fuseki 2.3.1 2015-12-08T09:24:07+0000
[2016-02-06 12:17:46] Config     INFO  FUSEKI_HOME=unset
[2016-02-06 12:17:46] Config     INFO  FUSEKI_BASE=C:\etc\fuseki
[2016-02-06 12:17:46] Servlet    INFO  Initializing Shiro environment
[2016-02-06 12:17:46] Config     INFO  Shiro file: file://C:\etc\fuseki\shiro.ini
[2016-02-06 12:17:46] Config     INFO  Configuration file: C:\etc\fuseki\config.ttl
[2016-02-06 12:17:47] riot       WARN  [line: 5, col: 9 ] Bad IRI: <C:\etc\fuseki\config.ttl#> Code: 4/UNWISE_CHARACTER in PATH: The character matches no grammar rules of URIs/IRIs. These characters are permitted in RDF URI References, XML system identifiers, and XML Schema anyURIs.
[2016-02-06 12:17:47] Server     INFO  Started 2016/02/06 12:17:47 CET on port 4000

And the webapp starts and listens to port 4000.

Unfortunately the unit test never stops, and killing the unit test
leaves the webapp running, so there is still a way to go...

Trying to create a Jena Fuseki Windows Service installer (Was: Running Fuseki as a Daemon or Windows Service)

Posted by Steinar Bang <sb...@dod.no>.
Hi,

I am trying to use the windows-service-installer maven plugin to create
a windows installer that will install a windows service that will run
Jena Fuseki.
 https://github.com/alexkasko/windows-service-installer

My DaemonLauncher for Jena Fuseki, is here:
 https://github.com/steinarb/fusekiservice/blob/master/src/main/java/no/priv/bang/fuseki/fusekiservice/FusekiService.java

I have written a JUnit test that attempts to start and stop the service
(just to see if I can make it run at all).
 https://github.com/steinarb/fusekiservice/blob/master/src/test/java/no/priv/bang/fuseki/fusekiservice/FusekiServiceTest.java

The JUnit test currently fails with the following console output:
 [2016-01-31 18:21:38] FusekiService INFO  FUSEKI_HOME: null
 [2016-01-31 18:21:38] Server     ERROR Can't find resourceBase (tried webapp and src/main/webapp)
 [2016-01-31 18:21:38] Server     ERROR Failed to start

So my question is: what am I missing from the FusekiService.startDaemon() method?

I have been stealing code from here (mainly):
 https://github.com/apache/jena/blob/master/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java

The reason I haven tried using FusekiCmd, is that I would like to have
        JettyFuseki.instance.start();
in the startDaemon() method, and
        JettyFuseki.instance.join();
in the stopDaemon() method (unless I've misunderstood how they are
supposed to work...?)

The failing code, is in
 https://github.com/apache/jena/blob/master/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
in the JettyFuseki.createWebApp() method.

The code in createWebapp() looks like it expects a directory, with
WEB-INF/web.xml residing in that directory (ie. WEB-INF a subdirectly of
the webapp directory), so I have been toying with the idea of
downloading and unpacking the fuseki webapp in a directory and give that
directory.

But even if I could make that work in a JUnit test, I have no idea of
how to accomplish the same thing in a windows service installed by an
installer created by the windows-service-installer maven plugin...

And the ready packaged jena fuseki starts and runs from a single .jar,
so unpacking something shouldn't be necessary.

So how should I proceed with this?  Is this doable?

Thanks!


- Steinar

Re: Running Fuseki as a Daemon or Windows Service

Posted by Andy Seaborne <an...@apache.org>.
On 14/03/14 09:40, Ian Emmons wrote:
> I see a number of oblique references online to running Fuseki as a
> *nix daemon.  However, I see no clear procedure for doing so.  Is
> such documentation written anywhere?

See

https://svn.apache.org/repos/asf/jena/branches/jena-fuseki-new-ui/fuseki

for now.

It's normal init/service(8)  script.

> Also, and equally important to my customers, is there a way to run
> Fuseki as a Windows Service?

There is no reason why not if such a thing were contributed.  i don't 
know how to run java services on Windows.

There will be a .WAR version as well but maybe not for the first v2 
release.  It works; the setting up of the file area needs to be properly 
integrated into usual practice.

	Andy

>
> Thanks,
>
> Ian
>