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-reload reloads on changes of database file #501

Open
SmithChart opened this issue Oct 20, 2023 · 4 comments
Open

--live-reload reloads on changes of database file #501

SmithChart opened this issue Oct 20, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@SmithChart
Copy link
Contributor

Well, I've tested --live-reload on my current project. And I think I mostly like this feature :-) It mostly works as expected.

But: I am using a sqlite3 database (with the Django ORM). This means every change made to the database will lead to an updated file inside my project repository. And this leads to Lona reloading.
Looking at the implementation it's totally clear why this happens.

But I think we could exclude a few extensions from the watch without loosing anything.
watchfiles has filters in place: https://watchfiles.helpmanual.io/api/filters/#watchfiles.filters.DefaultFilter.ignore_entity_patterns
I would suggest to add a DefaultFilter to watchfiles.run_process(). And to add at least .sqlite3 to the ignore_entity_patterns list. If we keep our extensions to the filter list at a central place we could event update this list if new extensions come along that we do not want to watch.

What do you think about this?

@fscherf fscherf added the bug Something isn't working label Oct 21, 2023
@fscherf
Copy link
Member

fscherf commented Oct 21, 2023

Hi @SmithChart,

Thanks for this bug-report. I think the cleanest and most extensible way to handle this would be to have a Lona setting named LIVE_RELOAD_IGNORE or so. I will have to change the server setup code to have the settings available at such an early stage though.

Another way would be a .lonaignore file like docker has, but if possible I would want to keep the Lona settings as the central place for all configuration.

@SmithChart
Copy link
Contributor Author

Hi @fscherf,

I had skimmed though the commit introducing live reloading and I concluded that settings would not be available there. To be honest: I think to have this in the settings would be the best way to solve this. This would keep all settings in one place.

Another idea would be to use .gitignore-files present in working directory. Usually files with state should be ignored there, too.

@fscherf
Copy link
Member

fscherf commented Mar 19, 2024

Hi @SmithChart,

I played around with some solutions, but the more I think about this, the more I think it is not an actual bug. --live-reload waits for changes in the Lona project root, which always was about holding code, not data. Would you be ok with me just adding a line to the documentation stating something like "--live-reload waits for changes in you project root. Don't put your data there to avoid loops and weird behavior"?

@SmithChart
Copy link
Contributor Author

Hey @fscherf,
thanks for working on this. I guess you are right. Data for the project should not reside where the code is. Having it all in one directory is simply due to me being lazy.

Adding a note to the documentation may make it a little more clear how it should be done. But it would probably be fine without this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants