Skip to content
New issue

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

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

Already on GitHub? # to your account

Improve chrome refesh after a crash #367

Merged
merged 2 commits into from
Aug 23, 2021
Merged

Improve chrome refesh after a crash #367

merged 2 commits into from
Aug 23, 2021

Conversation

yrien30
Copy link
Contributor

@yrien30 yrien30 commented Feb 19, 2021

Since chrome_debug.log is re-created by chrome when it start. tail should use the -F flag instead of the -f flag.
https://unix.stackexchange.com/questions/410471/tail-f-but-when-the-file-is-deleted-and-re-created-not-appended

I suggest also to add a 1 second delay before refeshing chrome after a crash.

@guysoft
Copy link
Owner

guysoft commented Mar 4, 2021

Hey,

  1. why add --follow=name --retry? Did you get IO issues with the file? I mean it seems to work here.
  2. Also, would it be better to add sleep 0.5? Sorry if its a little pedantic, but it seems that if there is an error in the log, a refresh should happen right away.

The thing is I never really found a way to test all this and it would help if you had a spesific page or something that this solves the issue for. Otherwise I am pulling without any proof that it helps anyone.

@yrien30
Copy link
Contributor Author

yrien30 commented Mar 4, 2021

  1. why add --follow=name --retry? Did you get IO issues with the file? I mean it seems to work here.

Did not work in my case whit -f. It makes sense since chrome is deleting the logs when it starts. If you use -f then it will stop watching the file for changes after the file is deleted. When I switch to -F it works.

  1. Also, would it be better to add sleep 0.5? Sorry if its a little pedantic, but it seems that if there is an error in the log, a refresh should happen right away.

That may also work. (not tested this) I add delay because when I navigate to chrome://crash to simulate a crash then it does not refesh unless I add a delay.

@guysoft
Copy link
Owner

guysoft commented Mar 4, 2021

Ok,
Will merge this after 0.12.0 which is in RC is out, then it will go to the nightly

@yrien30
Copy link
Contributor Author

yrien30 commented May 7, 2021

Another way of doing it:

RestartOnCrash()
{
 while read LOGLINE; do
   if [[ $LOGLINE == *"ERROR"* ]] || [[ $LOGLINE == *"FATAL"* ]]; then
     echo "Refreshing after crash"
     echo "Restarting at `date` after a reported crash. Logline: ${LOGLINE}" >> /tmp/crashlog
     exec /home/pi/scripts/refresh
   fi
 done
}

chromium-browser --enable-logging=stderr --log-level=2 --v=0 2>&1 | RestartOnCrash

@guysoft
Copy link
Owner

guysoft commented Aug 12, 2021

Hey, did that branch change? I see no relevant code anymore

@yrien30
Copy link
Contributor Author

yrien30 commented Aug 13, 2021

Hey, did that branch change? I see no relevant code anymore

Hey. I didn't change anything. I just sent you how I ended up writing the log file. I have changed it after this to log to /var/syslog/chrome and have log rotation on this file.

@guysoft guysoft merged commit 8aca011 into guysoft:devel Aug 23, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants