Shutting down Morbo

359 views
Skip to first unread message

Garry Taylor

unread,
Jun 24, 2017, 1:31:30 PM6/24/17
to Mojolicious
I've written a home entertainment system running on a Raspberry Pi and the user interface is provided by Morbo.  On occasion I will need to stop Morbo to debug a newly encountered hiccup or to add some new features that require a clean start.  Hitting Ctrl-C on the command line gets me back to the command prompt and "mostly" shuts down Morbo, but frequently when I go to restart Morbo, I'll get a message from Mojo::IOLoop.pm (line 126) saying that the port is already in use.  So my question at the moment is actually two question:
  1. Should I shut down Morbo differently?  Start a new command prompt and issue a kill, for instance, or put a "hidden" exit command inside the GUI? (I don't want my 3 year old grandson shutting down the system accidently :-)  )
  2. Does anyone know the process that keeps the port open?  I could issue a kill to that after the fact, but none of the process names leaps out as being Morbo (or perl, for that matter)
       Thanks,
         Garry

Stefan Adams

unread,
Jun 25, 2017, 1:21:17 PM6/25/17
to mojolicious

On Sat, Jun 24, 2017 at 12:31 PM, Garry Taylor <mrpo...@gmail.com> wrote:
Hitting Ctrl-C on the command line gets me back to the command prompt and "mostly" shuts down Morbo, but frequently when I go to restart Morbo, I'll get a message from Mojo::IOLoop.pm (line 126) saying that the port is already in use.

That seems bizarre to me.  How many times do you try to restart morbo?  Over what time frame?  Hitting Ctrl-C is how you exit morbo, and it's a single process daemon, so I don't know what would be going on there.

On a separate note, Morbo is the development web server.  Have you thought about running your app under Hypnotoad?

Garry Taylor

unread,
Jun 25, 2017, 2:58:47 PM6/25/17
to mojol...@googlegroups.com
Hi Stefan,
    I am not normally restarting morbo many times a day (or even a week).  It is running on a Raspberry Pi attached to my TV, and whoever is watching TV is the sole client.  Normally I only have to restart morbo if I've got to update the SQLite database file that keeps a list of TV shows and movies to add new shows or movies to the list.  As to running hypnotoad, I seem to recall that I tried it when I first wrote the media server code and started it running, but ran into a situation where morbo actually worked better in that environment.  (I don't remember now if it was due to the more limited resources on the Pi, or if it was that fact that there is always going to be only one client, and hypnotoad seemed like overkill...)  I considered putting an "exit" inside the app itself as well but "die", "exit" and  "kill 'INT', $$" did not "quite" exit morbo and return to the command line. (Also tried 'QUIT', and 'TERM' but no clean exit from them either).
        Garry

Dan Book

unread,
Jun 25, 2017, 10:02:32 PM6/25/17
to mojol...@googlegroups.com
Hypnotoad and the prefork server it's based on launch 4 workers by default. If you don't need the concurrency then you can simply use the plain 'daemon' command. It will not watch for filesystem changes but it will be much less complex to run than morbo. Run like: `./myapp.pl daemon -l 'http://*:8080'`

See https://metacpan.org/pod/Mojolicious::Command::daemon for more info on the daemon command. Like morbo you use ctrl+C or a SIGINT to stop the server.

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscribe@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages