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

keystroke activated watchdog #1020

Merged
merged 3 commits into from Mar 19, 2020
Merged

keystroke activated watchdog #1020

merged 3 commits into from Mar 19, 2020

Conversation

@tehn
Copy link
Member

@tehn tehn commented Feb 25, 2020

further fixes #1014

in sequence, hold K3, K2, K1. if 10s elapses, services are restart.

however, weird thing i'm seeing:

despite systemctl restart norns-* it seems like only matron is being restarted? ie, i don't get the startup animation and things start almost immediately. running the same command on the command line does what we want?

@tehn tehn requested a review from catfact Feb 25, 2020
@catfact
Copy link
Collaborator

@catfact catfact commented Feb 25, 2020

I'll take a look later.. since matron is parent process of shell it's probably getting shut down prematurely?

@tehn tehn changed the title works keystroke activated watchdog Feb 25, 2020
if(stage==3) count++;
if(count==10) {
fprintf(stderr, "RESTARTING...\n");
system("systemctl restart norns-*");

This comment has been minimized.

@catfact

catfact Feb 26, 2020
Collaborator

yeah, pretty sure the plain system("systemctl ...) won't work because as soon as matron is stopped the child shell will also be killed.

this SO question has some ideas, namely:

  • system("setsid .... &")
  • something suspiciously complicated with fork(), execl(), waitpid() and so on

https://stackoverflow.com/questions/17599096/how-to-spawn-child-processes-that-dont-die-with-parent

@ngwese
Copy link
Member

@ngwese ngwese commented Feb 26, 2020

Another possibly more simple option (not tested) would be to define another systemd service which watches for changes to a specific file on disk and runs the service as a result.
https://www.linux.com/tutorials/systemd-services-monitoring-files-and-directories/

...one could imagine the file watcher service simple restarts the norns-* units and all matron needs to do is touch a file (which the watcher service or matron could clean up after restart)

@tehn
Copy link
Member Author

@tehn tehn commented Feb 26, 2020

pretty sure i fixed it with a nohup (i mean, testing, it works now)

@tehn
Copy link
Member Author

@tehn tehn commented Mar 1, 2020

anyone see a problem with this? tested and confirmed working. i should probably try more crash-scenarios, if anyone has suggestions

@simonvanderveldt
Copy link
Member

@simonvanderveldt simonvanderveldt commented Mar 1, 2020

Didn't we want to restart the whole system with key-combo? Otherwise the only way to restart with an unresponsive device is to kill the power with the button on the bottom.

Regarding testing: I'm not really sure how to really test if this works. One know case seems to be if the UI doesn't respond, maybe by creating an infinite loop in a script?
Alternatively maybe the time change induced SC hang? Or alternatively create a fake 100%+ load?

@tehn
Copy link
Member Author

@tehn tehn commented Mar 9, 2020

changed systemctl restart messages according to discussion w/ @catfact and @ngwese

@tehn tehn merged commit d8c6082 into master Mar 19, 2020
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@tehn tehn deleted the dogwatch branch Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants