How to properly stop a Swazoo Site?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to properly stop a Swazoo Site?

Tim M
Off and on I've been struggling with how I properly stop a Swazoo site. I
am running on my local machine, I create a site and then later decide to
cleanly stop it and #stop seems to let me still attache with my browser to
the site. If I try and shutdown the HTTPServer I then seem to no longer be
able to retstart my site on the same port (and have to use a new one). What
is the trick to this?

Also - if I want to make a ToGo application that has a little server in it,
are there any tips to this? I tried creating a little console app, but I
guess I need some little loop to keep things running in the console while
the Swazoo server processes my requests?

I create my site as follows:

site := (Sitenew)
        name: 'CCDashboard';
        addAlias:
                (SiteIdentifier
                        ip: '127.0.0.1'
                        port: 8303
                        host: 'localhost')].


I try and stop it like so:

site stop.

(I seem to need HTTPServer stop. to really make it stop though?)

Tim


Reply | Threaded
Open this post in threaded view
|

Re: How to properly stop a Swazoo Site?

Tim M
> I try and stop it like so:
>
> site stop.
>
> (I seem to need HTTPServer stop. to really make it stop though?)


Oops - mean to say HTTPServer shutDown


Reply | Threaded
Open this post in threaded view
|

Re: How to properly stop a Swazoo Site?

Steve Alan Waring
In reply to this post by Tim M
Hi Tim,

> If I try and shutdown the HTTPServer I then seem to no longer be
> able to retstart my site on the same port (and have to use a new one). What
> is the trick to this?

I am not sure ... the Swazoo version I am using does not have a
Site>>stop method, but does have a HTTPServer>> stop method ... which
sounds like the opposite to yours :)

An HTTPServer can have multiple sites, so I would guess that a
Site>>stop method would not shutdown the HTTPServer, unless the site
informs the HTTPServer, and the  HTTPServer checks to see if it is no
longer needed.

Debug Site>stop and step through to see what is going on.

> let me still attache with my browser to the site.

It would be worth opening a new browser (or waiting for a minute or so)
to make sure the browser is not reusing an existing connection.

> retstart my site on the same port

Again if this clears up after a couple of minutes it could be a
SO_REUSEADDR issue ... although I think all versions of Swazoo set the
SO_REUSEADDR option for their server sockets.

If it is not a SO_REUSEADDR issue, try debugging 'HTTPServer shutDown'
to see if it removes the sites. The old HTTPServer>> stop did not
effect its sites, but this may have been changed. Also worth checking
that it is closing the socket.

> Also - if I want to make a ToGo application that has a little server in it,
> are there any tips to this? I tried creating a little console app, but I
> guess I need some little loop to keep things running in the console while
> the Swazoo server processes my requests?

Off the top of my head, I would implement MySessionManager>>keepAlive
rather than doing a #loopWhile in #main.

Hope I have not muddied the waters too much :)

Steve
--
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to properly stop a Swazoo Site?

Esteban A. Maringolo
Steve Alan Waring escribió:
> Hi Tim,
>
>> If I try and shutdown the HTTPServer I then seem to no longer be
>> able to retstart my site on the same port (and have to use a new one). What
>> is the trick to this?
>
> I am not sure ... the Swazoo version I am using does not have a
> Site>>stop method, but does have a HTTPServer>> stop method ... which
> sounds like the opposite to yours :)

In the Swazoo version 1.1.4 you can stop a Site sending #stop, or
through SwazooServer singleton stopSite: 'siteName'.

> An HTTPServer can have multiple sites, so I would guess that a
> Site>>stop method would not shutdown the HTTPServer, unless the site
> informs the HTTPServer, and the  HTTPServer checks to see if it is no
> longer needed.
>
> Debug Site>stop and step through to see what is going on.
>
>> let me still attache with my browser to the site.
>
> It would be worth opening a new browser (or waiting for a minute or so)
> to make sure the browser is not reusing an existing connection.
>
>> retstart my site on the same port
>
> Again if this clears up after a couple of minutes it could be a
> SO_REUSEADDR issue ... although I think all versions of Swazoo set the
> SO_REUSEADDR option for their server sockets.

Yes, this is the default in ServerSocket2 also.

> If it is not a SO_REUSEADDR issue, try debugging 'HTTPServer shutDown'
> to see if it removes the sites. The old HTTPServer>> stop did not
> effect its sites, but this may have been changed. Also worth checking
> that it is closing the socket.

You can also inspect the instances of HTTPServer to see if there are
some zombies.

Regards,

--
Esteban.


Reply | Threaded
Open this post in threaded view
|

Re: How to properly stop a Swazoo Site?

Tim M
Hi Esteban/Steve

Thanks for the tips - it was a problem in my code, I had Zombies all over
the place.

My problem was that it seems that you have to explicitly add a site to Swazoo
with #addSite: otherwise #siteNamed: won't return it (just instantiating
a new Site just leaves it unconnected - which makes sense, however its a
shame that SwazooServer doesn't have a #siteNamed:ifAbsent: method that will
let you create and add a new site if its not found - I think that would be
much clearer).

Tim