question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Restarting webserver after soft reboot

See original GitHub issue

Dear Jean-Christophe,

we are very happy about the new release of your fine webserver library. For now, it looks like it works very stable on one of our FiPy devices sitting on our workbench.

We are in the process of porting the Terkin Datalogger [1] to MicroWebSrv2 and experienced this issue after exiting the program using CTRL+C and invoking a soft reboot using CTRL+D.

It looks like the listener does not go away and so, MicroWebSrv2 can do nothing about its IsRunning method suitable for detecting this. The Webserver isn’t actually running but it looks like XAsyncSocket does not give up it’s listening socket on program termination, so it is obvious it can’t bind again to the same port after coming back from the soft reboot.

It currently looks like that for us:

PYB: soft reboot

[...]

   15.6195 [terkin.network.core      ] INFO   : Setting up HTTP API
   15.6389 [terkin.api.http          ] INFO   : Starting HTTP server
MWS2-INFO> Stops the managed pool.
   15.6814 [terkin.network.core      ] ERROR  : Starting HTTP server failed
Traceback (most recent call last):
  File "network/core.py", line 126, in start_services
  File "network/core.py", line 146, in start_httpserver
  File "api/http.py", line 70, in start
  File "MicroWebSrv2/microWebSrv2.py", line 220, in StartManaged
  File "MicroWebSrv2/microWebSrv2.py", line 215, in StartManaged
  File "MicroWebSrv2/microWebSrv2.py", line 215, in StartManaged
  File "MicroWebSrv2/microWebSrv2.py", line 207, in StartManaged
  File "MicroWebSrv2/microWebSrv2.py", line 185, in StartInPool
MicroWebSrv2Exception: Cannot bind server on 0.0.0.0:80.

I believe we had a global variable on the module level to keep a reference to the MicroWebSrv reference, but this eventually stopped working after upgrading to a more recent version of Pycom MicroPython. We might also be wrong on that so MicroWebSrv might have been more graceful to us.

We figure it would be the best thing to invoke MicroWebSrv2 before shutting down, i.e. when quitting the program through CTRL+C or just before the “soft reboot”.

So, we are humbly asking whether you would see a way to get around this issue?

With kind regards, Andreas.

[1] https://github.com/hiveeyes/hiveeyes-micropython-firmware

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:38 (36 by maintainers)

github_iconTop GitHub Comments

1reaction
amotlcommented, Nov 15, 2019

All right. I will check this with the next iteration. Thanks again!

0reactions
jcziccommented, Nov 17, 2019

Yes, after a soft reset only 👍 Also, thank you for all Andreas!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performing hard and soft reboots - Leaseweb Knowledge Base
In the following cases, you may need to reboot your server: Install new software; Restart the processes; Restore connectivity to the system ...
Read more >
Reboot a server - - Rackspace
Click Start. Click the arrow next to Shut down and select Restart from the menu. Alternatively, you can initiate a soft reboot from...
Read more >
Restarting and rebooting servers - IBM
In the Cloud Manager, click Services. · Navigate to the server that you want to restart and click the Server Actions icon Server...
Read more >
How to Reboot or Restart your server? - YouTube
After you click on Graceful Server Reboot, you will redirected to a page where you have to confirm the reboot process by clicking...
Read more >
How to Restart a Server? - LLHOST INC.
There is a software (soft) and hardware (hard) reset. The soft reset is secure. After receiving the command, the server will wait until...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found