shon / converge

Simple settings management for Python (only) applications
MIT License
10 stars 8 forks source link

Ability to specify settings folder, app_mode and server in a .convergerc file. #1

Closed rohitkrai03 closed 7 years ago

rohitkrai03 commented 7 years ago

I am thinking of sending a PR for this. .convergerc file will contain extra parameters like folder, app_mode and server. From theses params converge will automatically import appropriate settings.py file. Does it make sense?

shon commented 7 years ago

No .rc doesn't make sense. Converge user may have multiple apps running in different modes as same unix user.

But yes folder support PR is welcome. Code should first detect if settings folder is there and use that over *_settings.py files. If folder is not there it will load *_settings.py files.

rohitkrai03 commented 7 years ago

What do you mean multiple apps running in different modes as same unix user? How will having a .rc file affect this? Also, converge still do have .app_mode file. So what if i want to make configuration a bit complex than just app_mode? What if i want to specify the server or folder in which to look for settings.py files?

We do have this requirement right now in goodweb.

shon commented 7 years ago

What do you mean multiple apps running in different modes as same unix user?

Say I am running multitple flask applications with different settings managed by converge

How will having a .rc file affect this?

.rc is specific to a user (or generally is). So one .rc will be shared by many apps which might not be ideal.

What if i want to specify the server or folder in which to look for settings.py files?

Then you have a settings directory with same *_settings.py files inside. Have converge check for settings directory first and if not found look for *_settings.py files.

rohitkrai03 commented 7 years ago

Multiple flask applications will have there own virtual environments with specific converge working just for that app.

.rc files generally mean Runtime Configurations like we have .babelrc file for babel configurations specified in it. So this will be specific to the app.

If i want to run the same app on two different servers with two different configurations, I'll have files like server1_dev_settings.py, server2_dev_settings.py, server1_prod_settings.py and server2_prod_settings.py. Now i will just have to configure the .convergerc file like below and everything will be configured automatically based on i am running on dev server or prod or server1 or server2.

app_mode = 'DEV'

settings_folder = 'settings'

server = 'server1'

Naming could be improved obviously.

shon commented 7 years ago

Ok. I buy this (mostly)

I was thinking on the lines of .bashrc .bash_profile which are at user level (not at app level) but having a .convergerc at app level perhaps makes sense.

Implementation

`-- settings
       |
       |-- server1
       |
       |-- server2
# .convergerc on server1 
--
SETTINGS_DIR = '<approot>/settings/server1'

# .convergerc on server2
--
SETTINGS_DIR = '<approot>/settings/server2'
rohitkrai03 commented 7 years ago

The above proposal makes sense. I was also thinking of putting specific server settings into subdirectories so that there's no need to server param in .rc file.

shon commented 7 years ago

Released converge 0.5 with rc support