oldmoe / litestack

MIT License
1.09k stars 57 forks source link

Allow configuration of litedb root path #34

Open loganmac opened 12 months ago

loganmac commented 12 months ago

I'm brand new to Litestack, I've just been playing with Rails + sqlite in production manually (setting the journal mode to WAL).

It would be nice if we could configure the Litesupport root outside of using an env variable so that I don't have to add yet another env variable to production, and it works the same as dev/staging.

What about using a Rails config initializer? If you are open to this idea, let's hash it out and then I'll create a PR for it.

wolfgangrittner commented 11 months ago

I ran into this too, and I share your sentiment of not wanting to add another env variable. litestack defaults to using the app's db folder (see here), which is usually not shared between deploys. Rails defaults to using the storage folder when you create a new app using sqlite as database, see here.

storage is usually shared across deploys one way or another, so would be a safer default that would just work out of the box for most setups I guess.

oldmoe commented 10 months ago

I haven't had a chance to look into this issue for a good while, @loganmac and @wolfgangrittner , are you still interested in discussing a solution for this? I believe a configuration option for the root path is a good idea, my main concern would be that it needs to work with and without Rails

loganmac commented 10 months ago

I’m game! @wolfgangrittner is right in that the db/ folder is perhaps not as sensible a default as the storage/ folder for Rails 7, although with many cloud providers they supply disks that are usually recommended to be mounted to something like /var/data (I think, I’m a few months out of date from my last SQLite/rails app on Render/Fly).

I think a rails initializer that just called to the initialize options of the library would work pretty well.

oldmoe commented 10 months ago

Yes, setting the environment explicitly could be an option.

I was also thinking of eventually deprecating the different .yml config files per component and instead introducing a global litestack.yml that would include both global and per component configuration.