Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the webapp a service that starts on its own #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mgalardini
Copy link

Hi, thanks for putting together this system! Here's a proposed change to have the webserver and "operating system" turn on at startup, and have the various messages show up in a log using systemd. Hope this can be useful! Below the commit message with details.

These changes make the ChiBio webserver start in the background as a service after the board has been turned on

The chibio.service must be placed in /lib/systemd/ and enabled with the command systemctl enable chibio.service

The service can be stopped/started using systemctl:

  • systemctl start chibio.service
  • systemctl stop chibio.service
  • systemctl status chibio.service

Messages that used to be printed to stdout are now fed into systemd and can be read with timestamps using journalctl:

  • journalctl -u chibio.service
  • To follow new messages: journalctl -f -u chibio.service

Also added --timeout 0 to gunicorn as our board was sometimes shutting down the webserver mid-experiment because of a timeout; gunicorn by default has a 30 seconds timeout, with this change there is no limit

These changes make the ChiBio webserver start in the background
as a service after the board has been turned on

The `chibio.service` must be placed in `/lib/systemd/` and enabled
with the command `systemctl enable chibio.service`

The service can be stopped/started using `systemctl`:

* `systemctl start chibio.service`
* `systemctl stop chibio.service`
* `systemctl status chibio.service`

Messages that used to be printed to stdout are now fed into
`systemd` and can be read with timestamps using `journalctl`:

* `journalctl -u chibio.service`
* To follow new messages: `journalctl -f -u chibio.service`

Also added `--timeout 0` to `gunicorn` as our board was sometimes
shutting down the webserver mid-experiment because of a timeout;
gunicorn by default has a 30 seconds timeout, with this change
there is no limit
@mgalardini mgalardini changed the title Service Make the webapp a service that starts on its own Mar 31, 2023
@HarrisonSteel
Copy link
Owner

Hi Marco, this looks very interesting! I willl have to go through to understand it all in detail. If you are always running the web server - I suppose it now requires the user to have all the reactors plugged in/powered at Beaglebone start-up in order to be detected, though they could always restart the service if not. Have you found this is particularly common for your lab/use cases?

@HarrisonSteel
Copy link
Owner

The Gunicorn timeout is an interesting one, were you finding here that it was taking too long to upload the SysData into the web server, hence leading to the crash? Previously before we were downsampling the data stored there we had this issue over very long experiments whereby the quantity of data being loaded into the web interfaced increased with the length of experiment and eventually could overwhelm the server timeout...

@mgalardini
Copy link
Author

Hi sorry for the slow reply; I think the chibio web interface has a button to refresh the device list right? At any rate the person using the chibio usually turns everything on when the board is turned on.

For the gunicon problem, I'm not entirely sure what was causing it, but we suspect that it was perhaps a rare problem encountered because we had a browser open to the chibio interface during the whole duration of the experiment. If for any reason the webpage fails to reload data (or rather if it tool longer than 30 seconds to do so), then the whole chibio system would come down. We now have this change in place and for good measure we only open the web interface when needed.

Hope this clarifies things a bit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants