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

Implement lock file; improve trap management #56

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

friendly-bits
Copy link
Collaborator

@friendly-bits friendly-bits commented Aug 2, 2024

  • Implement lock file check, creation, removal
  • Create the trap only for actions which need it
  • stop(): kill any running adblock-lean PID's
  • status(): check the lock file and if it exists then report on it and exit
  • status(): support additional return codes
  • Only load config for actions which need it

@friendly-bits friendly-bits force-pushed the use-lock-file branch 2 times, most recently from 29af603 to 08e19cd Compare August 3, 2024 00:37
adblock-lean Outdated
}

if [ "${action}" != "help" ] && [ "${action}" != "gen_config" ]
rm_lock() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind amending the functions to:

x()
{

}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind amending the functions to

Done

@lynxthecat
Copy link
Owner

Thanks for this. Looks pretty good from a very cursory read through whilst gardening.

@friendly-bits
Copy link
Collaborator Author

friendly-bits commented Aug 3, 2024

Changed function declarations to

f ()
{
...
}

@friendly-bits
Copy link
Collaborator Author

Updated with slightly more compact variable assignment in report_pid_action().

@friendly-bits friendly-bits force-pushed the use-lock-file branch 2 times, most recently from 3de46d3 to d2becaf Compare August 3, 2024 10:49
@friendly-bits
Copy link
Collaborator Author

^ Yet more tinkering with code compaction in report_pid_action() :)
I think that's it.

@friendly-bits friendly-bits force-pushed the use-lock-file branch 2 times, most recently from 20858ff to d1afc49 Compare August 3, 2024 12:33
@friendly-bits
Copy link
Collaborator Author

^ Updated with more granular actions set in the lock file.
(and also slightly less spam in the log - we should consider reducing log spam further by utilizing the new print_msg() function for some of the less important messages, rather than log_msg())

@friendly-bits
Copy link
Collaborator Author

^ Fixed incorrect variable name in log_msg() (was _msg, should be msg).

@lynxthecat
Copy link
Owner

Should be able to test soon. Maybe @Wizballs might also be able to test too.

@friendly-bits friendly-bits force-pushed the use-lock-file branch 2 times, most recently from c27fedb to 76be692 Compare August 3, 2024 17:32
@friendly-bits
Copy link
Collaborator Author

friendly-bits commented Aug 3, 2024

^

  • mk_lock(): Only create the directory for the lock file if it doesn't exist yet (otherwise it could have errored out).
  • mk_lock(): Remove trailing . from the action string when writing the action to the lock file.

@Wizballs
Copy link
Contributor

Wizballs commented Aug 3, 2024

Morning everyone, looks like there has been heaps going on! Sure thing I'll give everything a test run.

@Wizballs
Copy link
Contributor

Wizballs commented Aug 3, 2024

@lynxthecat Tested multiple different times and service commands with the file lock. I can't find any failure conditions, so I think this PR is good.

@friendly-bits That's really quite neat how it outputs what action is currently being performed. Also I saw another PR where stop/resume/pause was fixed. Tested these also since I was here, all working well again.

@friendly-bits
Copy link
Collaborator Author

^

  • Action stop: require cleanup (it wasn't removing /var/run/adblock-lean/)
  • status(): swap return code 1 and return code 3 for consistency and so return code 1 means 'error' as per standard

(sorry, I found the issue with stop and then I also wanted to change the return codes of status. should be good to go now)

@friendly-bits
Copy link
Collaborator Author

^ Change function name from advert_action to reg_action.

@friendly-bits
Copy link
Collaborator Author

^

  • Fix restart/reload when adblock-lean is running
  • Fix the resume action when blocklist compression is enabled

@lynxthecat lynxthecat merged commit e89a176 into lynxthecat:master Aug 4, 2024
@lynxthecat
Copy link
Owner

Seems to work well. This evidently required some careful thought and coding. Terrific job @friendly-bits!

@friendly-bits friendly-bits deleted the use-lock-file branch August 5, 2024 09:19
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.

3 participants