You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "jose.garnica.lomeli" <jo...@protonmail.com> on 2023/06/12 16:00:57 UTC

Persist bundle status in karaf

Hello everyone,

Currently I have some bundles in my karaf solution starting by default as resolved, in just in specific scenarios when we need active them we execute the command bundle:start <bundle> but we want a find a option to persisit that configuration, to avoid re-start the bundle manually when the karaf instance is restarted.

Maybe we can use a property file in the CFG file to save the status of bundle(active or resolved) but I am not sure if this the best approach or karaf provide a way to do it?

Sent with [Proton Mail](https://proton.me/) secure email.

Re: Persist bundle status in karaf

Posted by João Assunção <jo...@exploitsys.com>.
Hello Jose.
Have you checked declarative services ?
I suspect your use case is probably more easily achievable using a
declarative service component. The component can be configured to
start/stop (activate/deactivate) based on the presence of a configuration.

Regards,
João Assunção

Email: joao.assuncao@exploitsys.com
Mobile: +351 916968984
Phone: +351 211933149
Web: www.exploitsys.com




On Mon, Jun 12, 2023 at 5:01 PM jose.garnica.lomeli <
jose.garnica.lomeli@protonmail.com> wrote:

> Hello everyone,
>
> Currently I have some bundles in my karaf solution starting by default as
> resolved, in just in specific scenarios when we need active them we execute
> the command bundle:start <bundle> but we want a find a option to persisit
> that configuration, to avoid re-start the bundle manually when the karaf
> instance is restarted.
>
>
> Maybe we can use a property file in the CFG file to save the status of
> bundle(active or resolved) but I am not sure if this the best approach or
> karaf provide a way to do it?
>
>
>
> Sent with Proton Mail <https://proton.me/> secure email.
>

Re: Persist bundle status in karaf

Posted by Steinar Bang <sb...@dod.no>.
>>>>> "jose.garnica.lomeli" <jo...@protonmail.com>:

> Currently I have some bundles in my karaf solution starting by default
> as resolved, in just in specific scenarios when we need active them we
> execute the command bundle:start <bundle> but we want a find a option
> to persisit that configuration, to avoid re-start the bundle manually
> when the karaf instance is restarted.

I almost never (except for debugging why a bundle won't load, which was
something I used to do a lot, but now can't remember the last time I
did...) do bundle:start.

I write my karaf applications as a "cloud of bundles" with SCR/DD'S and
then use karaf features (thanks for karaf features, JB!) to load and
start the bundles (which thanks to the magic of SCR/DS interconnects and
creates the applications).

I have tried to outline what I do here
 https://steinar.bang.priv.no/2020/04/05/composing-applications-with-karaf-features/

(But while it all is clear and simple in my head, I don't feel I managed
to put that clarity into text...:-) )

Anyway: what I always have experienced, is that when I load my
applications using features, the feature loading is persisted, so that
if karaf is stopped and then started, the same features are loaded.

I think this happens when you use bundle:start on individual bundles as
well, but, as I said, I haven't used it in a while.

The stored state is in the data directory in a running karaf, so if you
wish to start with a clean slate, just delete the data directory.

This is what I do in my karaf debian package, it was necessary to make
upgrades work.

Reinstalling all applications running in the same karaf instance after
an upgrade was a boring chore, so I created a master feature to install
all apps ("one feature to load them all, one feature to bind them"), and
what I do after a reinstall is to ssh into the running karaf instance,
and do:
 feature:repo-add mvn:no.priv.bang.myapps/myapps/LATEST/xml/features
 feature:install myapps

The master feature repository, looks like this:
 https://github.com/steinarb/myapps/blob/master/src/main/filtered-resources/feature.xml

My applications are built on top of:
 - pax-jdbc
 - pax-web (thanks Grzegorz!)
 - apache shiro (for authentication and authorization)


Re: Persist bundle status in karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi

it depends what you do in your activator. If the activator doesn't
start by default, you can check a config in the activator and start or
not.

Regards
JB

On Mon, Jun 12, 2023 at 6:00 PM jose.garnica.lomeli
<jo...@protonmail.com> wrote:
>
> Hello everyone,
>
> Currently I have some bundles in my karaf solution starting by default as resolved, in just in specific scenarios when we need active them we execute the command bundle:start <bundle> but we want a find a option to persisit that configuration, to avoid re-start the bundle manually when the karaf instance is restarted.
>
>
> Maybe we can use a property file in the CFG file to save the status of bundle(active or resolved) but I am not sure if this the best approach or karaf provide a way to do it?
>
>
>
> Sent with Proton Mail secure email.