Closed Pensarfeo closed 5 years ago
Can you just print the message right before calling runServer()
?
The two things are not the same. Is the answer no then?
I guess it's not clear to me what you mean by "when the server started." I meant the time that the application started (via runServer
). Do you mean something else, like the time that the server booted up?
Yeah, after the server is up and its ready to respond! For anyone familiar with node, that's when the string 'listening on 3001'
is printed (server.listen
is the equivalent of runServer
)
server.listen(3001, () => console.log('listening on 3001'))
My understanding of your example is that the call to server.listen()
is asynchronous, and console.log()
will be executed as soon as the server starts.
httpuv is different. runServer()
starts the server synchronously, so when it returns, it will be listening on the port. So you can put a cat()
or print()
right after the call to runServer()
.
Hi, is there a way to know when the server started and, for example, print a message?