You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Sam Lee <sk...@gmail.com> on 2012/08/21 17:46:09 UTC

shutdown all servlets except felix web console?

Hey,

When deploying OSGi bundles through Felix Web Console,  I want to block all
traffic to the sling instance. But, still able to deploy OSGi bundles.

The reason is because incoming traffic during deployment freezes instance
(have to kill -9).

Thanks.

Re: shutdown all servlets except felix web console?

Posted by Carsten Ziegeler <cz...@apache.org>.
If they're tied to a start level once you reach the final start level
everything is up.

Carsten

2012/8/22 Bertrand Delacretaz <bd...@apache.org>:
> On Wed, Aug 22, 2012 at 11:03 AM, Carsten Ziegeler <cz...@apache.org> wrote:
>> Why not simply decreasing the start level that only the web console
>> runs, installing the new stuff, and increasing the start level again?...
>
> Good idea, but note that you might still have transient states when
> upgraded/replaced bundles start coming back up and not all of them are
> ready. The filter that I mentioned earlier can help cover those cases.
>
> -Bertrand



-- 
Carsten Ziegeler
cziegeler@apache.org

Re: shutdown all servlets except felix web console?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Aug 22, 2012 at 11:03 AM, Carsten Ziegeler <cz...@apache.org> wrote:
> Why not simply decreasing the start level that only the web console
> runs, installing the new stuff, and increasing the start level again?...

Good idea, but note that you might still have transient states when
upgraded/replaced bundles start coming back up and not all of them are
ready. The filter that I mentioned earlier can help cover those cases.

-Bertrand

Re: shutdown all servlets except felix web console?

Posted by Sam Lee <sk...@gmail.com>.
changing run level on a live server = disaster. Felix is simply bad.


On Wed, Aug 22, 2012 at 5:03 AM, Carsten Ziegeler <cz...@apache.org>wrote:

> Why not simply decreasing the start level that only the web console
> runs, installing the new stuff, and increasing the start level again?
>
> Carsten
>
> 2012/8/22 Bertrand Delacretaz <bd...@apache.org>:
> > On Tue, Aug 21, 2012 at 11:02 PM, Sam Lee <sk...@gmail.com> wrote:
> >> The component gets disabled during deployment  :P.
> >>
> >> Maybe I need to create a separate OSGi bundle  for this....
> >
> > Yes, if the bundle that contains your filter is affected by upgrades
> > that will stop the filter ;-)
> >
> > BTW I just remembered that we do have such a filter in Sling, see
> >
> https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/startup-filter
> > and SLING-2347 - sorry that I didn't mention that earlier.
> >
> > The use case is slightly different but that might be useful.
> >
> > -Bertrand
>
>
>
> --
> Carsten Ziegeler
> cziegeler@apache.org
>

Re: shutdown all servlets except felix web console?

Posted by Carsten Ziegeler <cz...@apache.org>.
Why not simply decreasing the start level that only the web console
runs, installing the new stuff, and increasing the start level again?

Carsten

2012/8/22 Bertrand Delacretaz <bd...@apache.org>:
> On Tue, Aug 21, 2012 at 11:02 PM, Sam Lee <sk...@gmail.com> wrote:
>> The component gets disabled during deployment  :P.
>>
>> Maybe I need to create a separate OSGi bundle  for this....
>
> Yes, if the bundle that contains your filter is affected by upgrades
> that will stop the filter ;-)
>
> BTW I just remembered that we do have such a filter in Sling, see
> https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/startup-filter
> and SLING-2347 - sorry that I didn't mention that earlier.
>
> The use case is slightly different but that might be useful.
>
> -Bertrand



-- 
Carsten Ziegeler
cziegeler@apache.org

Re: shutdown all servlets except felix web console?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, Aug 21, 2012 at 11:02 PM, Sam Lee <sk...@gmail.com> wrote:
> The component gets disabled during deployment  :P.
>
> Maybe I need to create a separate OSGi bundle  for this....

Yes, if the bundle that contains your filter is affected by upgrades
that will stop the filter ;-)

BTW I just remembered that we do have such a filter in Sling, see
https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/startup-filter
and SLING-2347 - sorry that I didn't mention that earlier.

The use case is slightly different but that might be useful.

-Bertrand

Re: shutdown all servlets except felix web console?

Posted by Sam Lee <sk...@gmail.com>.
The component gets disabled during deployment  :P

Maybe I need to create a separate OSGi bundle  for this....

On Tue, Aug 21, 2012 at 4:46 PM, Sam Lee <sk...@gmail.com> wrote:

> @SlingFilter(scope = SlingFilterScope.REQUEST, order = Integer.MAX_VALUE,
> generateComponent = false)
> @Component(metatype = true, immediate = false, enabled = false)
> public class BlockAllButFelixFilter implements Filter {
>     @Override
>     public void doFilter(ServletRequest request, ServletResponse response,
> FilterChain chain) throws IOException, ServletException {
>         if (request instanceof HttpServletRequest && response instanceof
> HttpServletResponse) {
>             final HttpServletRequest httpRequest = (HttpServletRequest)
> request;
>             final HttpServletResponse httpResponse = (HttpServletResponse)
> response;
>
>             if (!httpRequest.getPathInfo().startsWith("/system/console/"))
> {
>                 httpResponse.sendError(503, "deployment on going...");
>                 return;
>
>             }
>         }
>
>         chain.doFilter(request, response);
>     }
>
>
>
> then you can control this in deployment script:
> curl -s -v -u admin:admin -d "action=enable"
> http://localhost:8080/system/console/components/saml.BlockAllButFelixFilter> /dev/null
> curl -s -v -u admin:admin -d "action=disable"
> http://localhost:8080/system/console/components/saml.BlockAllButFelixFilter> /dev/null
>
>
> On Tue, Aug 21, 2012 at 11:56 AM, Sam Lee <sk...@gmail.com> wrote:
>
>> Thanks.
>> Do you have an example of such servlet filter?
>>
>>
>>
>> On Tue, Aug 21, 2012 at 11:53 AM, Bertrand Delacretaz <
>> bdelacretaz@apache.org> wrote:
>>
>>> Hi,
>>>
>>> On Tue, Aug 21, 2012 at 5:46 PM, Sam Lee <sk...@gmail.com> wrote:
>>> > When deploying OSGi bundles through Felix Web Console,  I want to
>>> block all
>>> > traffic to the sling instance. But, still able to deploy OSGi
>>> bundles....
>>>
>>> I've been doing that with a Servlet Filter that you activate before
>>> doing your upgrades, which returns a 503 status code with an
>>> explanation, and you disable it when done.
>>>
>>> -Bertrand
>>>
>>
>>
>

Re: shutdown all servlets except felix web console?

Posted by Sam Lee <sk...@gmail.com>.
@SlingFilter(scope = SlingFilterScope.REQUEST, order = Integer.MAX_VALUE,
generateComponent = false)
@Component(metatype = true, immediate = false, enabled = false)
public class BlockAllButFelixFilter implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
        if (request instanceof HttpServletRequest && response instanceof
HttpServletResponse) {
            final HttpServletRequest httpRequest = (HttpServletRequest)
request;
            final HttpServletResponse httpResponse = (HttpServletResponse)
response;

            if (!httpRequest.getPathInfo().startsWith("/system/console/")) {
                httpResponse.sendError(503, "deployment on going...");
                return;

            }
        }

        chain.doFilter(request, response);
    }



then you can control this in deployment script:
curl -s -v -u admin:admin -d "action=enable"
http://localhost:8080/system/console/components/saml.BlockAllButFelixFilter>
/dev/null
curl -s -v -u admin:admin -d "action=disable"
http://localhost:8080/system/console/components/saml.BlockAllButFelixFilter>
/dev/null

On Tue, Aug 21, 2012 at 11:56 AM, Sam Lee <sk...@gmail.com> wrote:

> Thanks.
> Do you have an example of such servlet filter?
>
>
>
> On Tue, Aug 21, 2012 at 11:53 AM, Bertrand Delacretaz <
> bdelacretaz@apache.org> wrote:
>
>> Hi,
>>
>> On Tue, Aug 21, 2012 at 5:46 PM, Sam Lee <sk...@gmail.com> wrote:
>> > When deploying OSGi bundles through Felix Web Console,  I want to block
>> all
>> > traffic to the sling instance. But, still able to deploy OSGi
>> bundles....
>>
>> I've been doing that with a Servlet Filter that you activate before
>> doing your upgrades, which returns a 503 status code with an
>> explanation, and you disable it when done.
>>
>> -Bertrand
>>
>
>

Re: shutdown all servlets except felix web console?

Posted by Sam Lee <sk...@gmail.com>.
Thanks.
Do you have an example of such servlet filter?


On Tue, Aug 21, 2012 at 11:53 AM, Bertrand Delacretaz <
bdelacretaz@apache.org> wrote:

> Hi,
>
> On Tue, Aug 21, 2012 at 5:46 PM, Sam Lee <sk...@gmail.com> wrote:
> > When deploying OSGi bundles through Felix Web Console,  I want to block
> all
> > traffic to the sling instance. But, still able to deploy OSGi bundles....
>
> I've been doing that with a Servlet Filter that you activate before
> doing your upgrades, which returns a 503 status code with an
> explanation, and you disable it when done.
>
> -Bertrand
>

Re: shutdown all servlets except felix web console?

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

On Tue, Aug 21, 2012 at 5:46 PM, Sam Lee <sk...@gmail.com> wrote:
> When deploying OSGi bundles through Felix Web Console,  I want to block all
> traffic to the sling instance. But, still able to deploy OSGi bundles....

I've been doing that with a Servlet Filter that you activate before
doing your upgrades, which returns a 503 status code with an
explanation, and you disable it when done.

-Bertrand