Maybe starting the server from the REPL is the better idea. Right now I do it 
through raco (redirecting commands of form `raco pollen ...`, including `raco 
pollen start`, to a special pollen/raco module that handles them)


On Aug 27, 2014, at 3:12 PM, Jay McCarthy <[email protected]> wrote:

> Yes, although I actually assumed that you would start your server from
> a real Racket REPL, rather than implement your own REPL, so you
> wouldn't need to wait on anything. But what you wrote will work too.
> 
> Jay
> 
> On Wed, Aug 27, 2014 at 4:33 PM, Matthew Butterick <[email protected]> wrote:
>> Helpful, thanks. I have my `serve/servlet` within a `start-server` function 
>> rather than at the top level. Quick experimentation suggests that 
>> `thread-wait` is needed in this case (?):
>> 
>> (define (start-server)
>>    (setup-chores ...)
>>    (define server-t (thread (lambda () (serve/servlet ...))))
>>    (define repl-t (thread (lambda () ...)))
>>    (thread-wait server-t))
>> 
>> Otherwise, I'll see how far I get.
>> 
>> 
>> 
>> On Aug 27, 2014, at 10:58 AM, Jay McCarthy <[email protected]> wrote:
>> 
>>> Hi Matthew,
>>> 
>>> You can run serve/servlet in a separate thread and continue to
>>> interact with any functions you want:
>>> 
>>> (define server-t (thread (lambda () (serve/servlet ...))))
>>> 
>>> You could then use something like xrepl to start doing new stuff.
>>> There's nothing the Web server would need to do necessarily.
>>> 
>>> However, if you wanted to change how the server was running, you might
>>> need to adjust some things. For instance, you could put the main
>>> request->response function in a box that you could change. You could
>>> kill the server-t thread and then create another one to restart the
>>> server with new parameters.
>>> 
>>> Is that a useful sketch?
>>> 
>>> Jay
>>> 
>>> 
>>> On Wed, Aug 27, 2014 at 1:33 PM, Matthew Butterick <[email protected]> wrote:
>>>> The main engine of my Pollen system is a project webserver that's started 
>>>> from the command line, uses serve/servlet, and sends the usual status & 
>>>> error messages to the terminal window.
>>>> 
>>>> I was thinking it would be handy to be able to keep an input prompt in 
>>>> that terminal window to be able to issue commands without stopping the 
>>>> server, switching to another window, etc.
>>>> 
>>>> Is there a straightforward approach to this in terms of program design, or 
>>>> would it introduce annoying complications?
>>>> 
>>>> My understanding of serve/servlet is that it can only do one thing, which 
>>>> is listen & respond to TCP requests on a certain port. So for this 
>>>> REPL-ish feature, there would have to be a separate listenener/response 
>>>> mechanism. Is that something one would accomplish with threads? Or is 
>>>> there a better way? (Or no way.)
>>>> 
>>>> An approach I've seen with other web-development systems is to put an 
>>>> admin panel in the browser (by injecting it into the HTML of the output 
>>>> web page). But that's inherently hinky because it pollutes your output.
>>>> ____________________
>>>> Racket Users list:
>>>> http://lists.racket-lang.org/users
>>> 
>>> 
>>> 
>>> --
>>> Jay McCarthy
>>> http://jeapostrophe.github.io
>>> 
>>>          "Wherefore, be not weary in well-doing,
>>>     for ye are laying the foundation of a great work.
>>> And out of small things proceedeth that which is great."
>>>                         - D&C 64:33
>> 
>> 
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
> 
> 
> 
> -- 
> Jay McCarthy
> http://jeapostrophe.github.io
> 
>           "Wherefore, be not weary in well-doing,
>      for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>                          - D&C 64:33


____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to