You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by David Bosschaert <da...@gmail.com> on 2014/07/23 09:20:53 UTC

Command to start Sling launchpad, expand files, then exit

Hi all,

I was wondering whether there is a way to start the Sling launchpad,
let it do the expansion of all the embedded files and then exit.
I'd like to be able to do this from a shell script, so something
straightforward would be nice :)

Thanks!

David

Re: Command to start Sling launchpad, expand files, then exit

Posted by Carsten Ziegeler <cz...@apache.org>.
Even that, sure - the listener is triggered by our ready service and can
then simply execute all (or a configured set of) health checks

And then signal this to somewhere - in other installations we use a simple
socket connection for the signal - observer waits for some bytes on that
socket, the listener puts them there once startup is finished.

Carsten


2014-07-23 17:03 GMT+02:00 Bertrand Delacretaz <bd...@apache.org>:

> On Wed, Jul 23, 2014 at 4:07 PM, Carsten Ziegeler <cz...@apache.org>
> wrote:
> > ...We have the startup support and
> > you can simply register a listener doing the trick...
>
> What do you mean by "doing the trick"? Validating that health checks
> pass before exiting?
>
> -Bertrand
>



-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: Command to start Sling launchpad, expand files, then exit

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Jul 23, 2014 at 4:07 PM, Carsten Ziegeler <cz...@apache.org> wrote:
> ...We have the startup support and
> you can simply register a listener doing the trick...

What do you mean by "doing the trick"? Validating that health checks
pass before exiting?

-Bertrand

Re: Command to start Sling launchpad, expand files, then exit

Posted by Carsten Ziegeler <cz...@apache.org>.
Why do you want something we already have? We have the startup support and
you can simply register a listener doing the trick. That is in fact our
ready service.
Let's not overcomplicate this thing

Carsten


2014-07-23 15:12 GMT+02:00 Bertrand Delacretaz <bd...@apache.org>:

> On Wed, Jul 23, 2014 at 3:07 PM, David Bosschaert
> <da...@gmail.com> wrote:
> > ...So, e.g.:
> >   -x "(objectClass=o.a.s.SlingReady)"
> > or
> >   -x
> > Where the latter uses a default filter...
>
> Sounds great to me!
>
> We already have something like that in
> contrib/extensions/startup-filter and startup-filter-disabler, the
> latter registers a StartupFilterDisabler service to remove the HTTP
> 503 filter that the former registers at startup.
>
> What you suggest is more generic, I like it. We could then rewrite
> those modules to use the SlingReady service. Which makes me think that
> the default filter that you suggest should come from a framework
> property.
>
> -Bertrand
>



-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: Command to start Sling launchpad, expand files, then exit

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Jul 23, 2014 at 3:07 PM, David Bosschaert
<da...@gmail.com> wrote:
> ...So, e.g.:
>   -x "(objectClass=o.a.s.SlingReady)"
> or
>   -x
> Where the latter uses a default filter...

Sounds great to me!

We already have something like that in
contrib/extensions/startup-filter and startup-filter-disabler, the
latter registers a StartupFilterDisabler service to remove the HTTP
503 filter that the former registers at startup.

What you suggest is more generic, I like it. We could then rewrite
those modules to use the SlingReady service. Which makes me think that
the default filter that you suggest should come from a framework
property.

-Bertrand

Re: Command to start Sling launchpad, expand files, then exit

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Wed, Jul 23, 2014 at 3:07 PM, David Bosschaert
<da...@gmail.com> wrote:
...
> So, e.g.:
>   -x "(objectClass=o.a.s.SlingReady)"
> or
>   -x
> Where the latter uses a default filter...

I thought a bit more about this, and if you implement something it
could be made generally useful by just executing "sling commands",
which are not necessarily meant to stop Sling. There might even be a
way to do this out of the box using run modes.

-Bertrand

Re: Command to start Sling launchpad, expand files, then exit

Posted by David Bosschaert <da...@gmail.com>.
Or maybe a command line option with an OSGi service filter? When a
service that matches the filter is registered then shut down the
container... Maybe with a reasonable default too.
So, e.g.:
  -x "(objectClass=o.a.s.SlingReady)"
or
  -x
Where the latter uses a default filter...

Just a thought :)

David

On 23 July 2014 13:59, Bertrand Delacretaz <bd...@apache.org> wrote:
> hi David,
>
> On Wed, Jul 23, 2014 at 12:16 PM, David Bosschaert
> <da...@gmail.com> wrote:
>> ...I guess I was thinking it might be useful to add a command line option
>> to the launcher, something like:
>>   -x extract the sling files and then exit..
>
> As Carsten says the problem is not just extracting files, if for
> example you want to create a Docker image that will startup quickly
> it's best to wait until the application is ready before considering
> the image fully built.
>
> My suggestion is to add a command-line option as you suggest, and make
> the logic that decides when to exit configurable. That can simply be a
> combination of StartupListener and health checks, where a
> configuration says "consider this instance ready when N health checks
> tagged with 'startup' pass" for example. That would be a generally
> useful addition IMO. Having to configure N is not ideal but I'm not
> sure how you can guarantee that all required health checks are present
> otherwise.
>
> -Bertrand

Re: Command to start Sling launchpad, expand files, then exit

Posted by Bertrand Delacretaz <bd...@apache.org>.
hi David,

On Wed, Jul 23, 2014 at 12:16 PM, David Bosschaert
<da...@gmail.com> wrote:
> ...I guess I was thinking it might be useful to add a command line option
> to the launcher, something like:
>   -x extract the sling files and then exit..

As Carsten says the problem is not just extracting files, if for
example you want to create a Docker image that will startup quickly
it's best to wait until the application is ready before considering
the image fully built.

My suggestion is to add a command-line option as you suggest, and make
the logic that decides when to exit configurable. That can simply be a
combination of StartupListener and health checks, where a
configuration says "consider this instance ready when N health checks
tagged with 'startup' pass" for example. That would be a generally
useful addition IMO. Having to configure N is not ideal but I'm not
sure how you can guarantee that all required health checks are present
otherwise.

-Bertrand

Re: Command to start Sling launchpad, expand files, then exit

Posted by Carsten Ziegeler <cz...@apache.org>.
I guess if you want to speed up startup time, it would make sense to not
just extract but also run the initial install phase - the framework will
already have it's state, content is already installed etc.
We have the startup handler stuff in Sling which allows to register startup
listener services, org.apache.sling.launchpad.api.StartupListener - an
implementation could use some mechanism to signal that the installation is
complete, e.g. sending text to a port etc. I guess that's the most reliable
way.

In addition, if you want to use extracted/started files to spin up more
than one instance, make sure to remove the file containing the unique
sling.id which is in the private data area of the settings bundle and named
sling.id.file - otherwise you'll end up with multiple instances using the
same id and you wouldn't be able to connect them through the topology.

Regards
Carsten


2014-07-23 12:16 GMT+02:00 David Bosschaert <da...@gmail.com>:

> Hi Anjan,
>
> Thanks for the suggestion. Is this reliable though especially since
> this may be running on a wide variety of machines (very slow ones and
> very fast ones)? How long should the sleep be?
>
> I guess I was thinking it might be useful to add a command line option
> to the launcher, something like:
>   -x extract the sling files and then exit
>
> The main purpose here is to speed up startup time for subsequent runs :)
>
> Cheers,
>
> David
>
> On 23 July 2014 11:07, anjan <po...@gmail.com> wrote:
> > David, if you include a sleep command between the below two commands for
> > starting and stopping, it should work.
> >
> > java -jar sling.jar start -j localhost:0
> > java -jar sling.jar stop -j localhost:0
> >
> > Of course, the start command should open a different terminal and also
> the
> > stop command.
> >
> >
> >
> > --
> > View this message in context:
> http://apache-sling.73963.n3.nabble.com/Command-to-start-Sling-launchpad-expand-files-then-exit-tp4036574p4036608.html
> > Sent from the Sling - Users mailing list archive at Nabble.com.
>



-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: Command to start Sling launchpad, expand files, then exit

Posted by David Bosschaert <da...@gmail.com>.
Hi Anjan,

Thanks for the suggestion. Is this reliable though especially since
this may be running on a wide variety of machines (very slow ones and
very fast ones)? How long should the sleep be?

I guess I was thinking it might be useful to add a command line option
to the launcher, something like:
  -x extract the sling files and then exit

The main purpose here is to speed up startup time for subsequent runs :)

Cheers,

David

On 23 July 2014 11:07, anjan <po...@gmail.com> wrote:
> David, if you include a sleep command between the below two commands for
> starting and stopping, it should work.
>
> java -jar sling.jar start -j localhost:0
> java -jar sling.jar stop -j localhost:0
>
> Of course, the start command should open a different terminal and also the
> stop command.
>
>
>
> --
> View this message in context: http://apache-sling.73963.n3.nabble.com/Command-to-start-Sling-launchpad-expand-files-then-exit-tp4036574p4036608.html
> Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Command to start Sling launchpad, expand files, then exit

Posted by anjan <po...@gmail.com>.
David, if you include a sleep command between the below two commands for
starting and stopping, it should work.

java -jar sling.jar start -j localhost:0
java -jar sling.jar stop -j localhost:0

Of course, the start command should open a different terminal and also the
stop command.



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Command-to-start-Sling-launchpad-expand-files-then-exit-tp4036574p4036608.html
Sent from the Sling - Users mailing list archive at Nabble.com.