Not sure I understand your notion of "service changed" :-)
I use the term "service" in a colloquial sense. I don't mean "OSGi service".

Let me try it that way:

My release build produces a self-contained tarball of the entire code of my 
service.
My "devops" automation (in Jenkins) deploys the tarball on a test VM together 
with the production data.

After this deployment, the very first time the Karaf container starts up, I 
want to run some initialization logic.
But only this very first time. Any subsequent Karaf container start up should 
not do this initialization any more.

-Max


On 06/07/2018 05:48 PM, Leschke, Scott wrote:
You mean the logic should only execute if the service is "changed", but not in 
the case where the service is stopped and restarted?

-----Original Message-----
From: Max Spring [mailto:[email protected]]
Sent: Thursday, June 07, 2018 7:40 PM
To: [email protected]
Subject: execute only at first startup?

I've got a Karaf-based service.
Whenever I deploy a new revision of my service, I need to execute some code 
only at the very first startup.
I have this first-time functionality available as a Karaf command which I 
currently run manually each time right after startup after a new deployment.
I'd like to automate this.

I'm thinking of using a marker file somewhere to indicate "first startup".
I'd have a new bundle checking for this file when it starts up. When it detect 
the file, the bundle executes my business logic initialization and then deletes 
the marker file.

Or, is there something better for this scenario?

-Max

Reply via email to