Clean with wrapper (windows service)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Clean with wrapper (windows service)

kisho
Hello,
I'm using the wrapper to start Karaf as a windows server. I need to clean
the data directory whenever the service started.
I tried to add several options in karaf-wrapper.conf:

E.G.:
set.default.KARAF_OPTS=clean

wrapper.app.parameter.1=clean


But this does not work.

Any suggestions?
Regards
Kisho
Reply | Threaded
Open this post in threaded view
|

Re: Clean with wrapper (windows service)

bocamel
Hi Kisho,

Did you ever find out how to do this?  I want to do the same.

Thanks,
John
Reply | Threaded
Open this post in threaded view
|

Re: Clean with wrapper (windows service)

bocamel
In reply to this post by kisho
I have also looked for a way to start Karaf clean as a service in the Windows environment.  One good thing about running Karaf as a service in Windows is that it can be automatically restarted when Windows is rebooted unexpectedly (e.g. the OS is patched and restarted).  But Karaf (at least 3.0.x) is not very kind to such restarts.  Often, after the reboot, while Karaf is restarted but some bundles do not get started successfully.  This has caused a lot of headaches.  This is why I needed to automatically start Karaf clean whenever the server is rebooted.

The workaround solution that I came up with is the following:

1. I installed the Karaf service so that it can only be started manually.  That is, no auto start.

2. Create a Windows scheduler task that runs at the startup (without requiring user login) to call a Windows command script.

3. The command script will do the following 3 things:

a) rmdir /S /Q [karaf-install-path]\data
b) net start [karaf-service-name]
c) timeout 20 seconds (to allow karaf to complete its startup), then call putty (or plink) to run a karaf shell script that will install my bundles:  putty -load "karaf" -m c:\test\my-karaf-script.sh

This will start Karaf cleanly and install all my bundles after Karaf has started up successfully.  I did try to install my bundles as boot features.  For some reason, it took a very long time for Karaf to start up them as boot features(in about 5 minutes).  If I start Karaf with its minimum features, then add my own features using the shell script, it takes less than 1 minute to start everything.

I wish Karaf can make three enhancements:

1) make it more tolerant to OS reboot.
2) allow clean option to be passed through the service wrapper so one start the Karaf service cleanly
3) allow a script to be configured to run after Karaf is fully started (i.e. all system bundles have been started, and all jar files in the deploy directory have been started)