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

Live update config file without restarting (RFC) #535

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Alexandero89
Copy link

So i wanted my instance to run on the server and while the docker container is running I can simply add URLs to the config.yaml that are automatically included in the search without needing to restart the instance.

I don't know if this function is even wanted here, but since its finished and works for me, I thought I would at least offer it.

The following functions are possible with this PR:

  • Edit config.yaml and changes are applied live without having to restart the server
  • If an error occurs in the edited config file, the change is not applied and the old config is still used.

Steps implemented to achieve these functions:

  • checking the correctness of a config has been outsourced to the check_config function
  • creation of the heartbeat has been outsourced to the get_heartbeat_instructions function
  • A setting "refresh_config: no" was added to config.yaml.dist under the "loop:" tab
  • When creating a config object, the timestamp at which the file was last changed on the file system is also saved
  • Each time a loop is executed, a check is made to see whether "refresh_config" is true. If so, a new config object is created and compared to see if the timestamps differ from each other
  • if the timestamp is more recent, the old config is replaced with the new one and all required objects are reinitialised
  • various helper methods and environment variables added
  • added readme content for the env variable

If this feature is also useful here, but would have to be adapted before it is merged, I am open to changes.

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (73a6229) 71.10% compared to head (ab74292) 66.75%.
Report is 2 commits behind head on main.

Files Patch % Lines
flathunter/config.py 60.00% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #535      +/-   ##
==========================================
- Coverage   71.10%   66.75%   -4.36%     
==========================================
  Files          41       41              
  Lines        2274     2292      +18     
  Branches      338      341       +3     
==========================================
- Hits         1617     1530      -87     
- Misses        552      662     +110     
+ Partials      105      100       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@codders codders left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request. It looks like a cool feature and I would like to merge it in. Just one question about the implementation.

@@ -10,6 +10,7 @@
loop:
active: yes
sleeping_time: 600
refresh_config: no
Copy link

Choose a reason for hiding this comment

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

Bit confused here. Doesn't setting 'refresh_config' to 'no' here actually enable it?

Copy link
Author

Choose a reason for hiding this comment

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

Why do you think so? I just tested and it is not reloading the config when the value ist set to "no"

@Alexandero89
Copy link
Author

I just noticed that my flathunt instance is taking around 4gb of ram after running for a while.
So i think i need to check for a memory leak and if its coming from my code changes or were in the original code.

will keep you updated.

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.

2 participants