[Cuis-dev] starting, stopping, and restarting WebServer

Mark Volkmann r.mark.volkmann at gmail.com
Wed Sep 25 09:09:21 PDT 2024


Thanks so much Mariano! That works great.

On Wed, Sep 25, 2024 at 7:55 AM Mariano Montone via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> No. I discovered how to do it. Call #listeOn: after #destroy:
>
> "1) Create server"
> server := WebServer new.
> server addService: '/' action: [:req | req send200Response: 'Hello,
> World!'].
> server listenOn: 3050.
>
> "2) Destroy the server"
> server destroy.
>
> "3) Restart the server"
>
> server listenOn: 3050
> El 25/9/24 a las 09:44, Mariano Montone escribió:
>
> What works for me is to detroy and then create the webserver instance
> again:
>
> "1) Create server (again)"
> server := WebServer new.
> server addService: '/' action: [:req | req send200Response: 'Hello,
> World!'].
> server listenOn: 3050.
>
> "2) Destroy the server"
> server destroy.
>
>
> Evaluate 1), then 2), then 1) again. I would be nice if there were a
> better way, but at least that's better than restarting the image.
>
>
>           Mariano
> El 24/9/24 a las 14:53, Mark Volkmann via Cuis-dev escribió:
>
> Here is a very simple use of the WebServer class that can be installed
> with
> Feature require: 'WebClient'. A fileOut containing this code is attached.
> The class name is BasicWebServer and it has the single instance variable
> server.
> It contains only these instance methods.
>
> initialize
>     server := WebServer new.
>     server addService: '/' action: [:req | req send200Response: 'Hello,
> World!'].
>
> start
>     server listenOn: 3000
>
> stop
>     server stopListener
>
> I can start the web server with:
>
> server := BasicWebServer new.
> server start.
>
> Then I can browse localhost:3000 and see "Hello, World!" in the web
> browser.
>
> I can stop the web server with:
>
> server stop.
>
> But I cannot start it again unless I restart the VM. Can someone please
> explain what else I can do to enable restarting the server without needing
> to restart the VM?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>


-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240925/4521f9b8/attachment-0001.htm>


More information about the Cuis-dev mailing list