Skip to content

Accept a config filename as an optional parameter to Ghost start-up.#1110

Closed
rektide wants to merge 1 commit intoTryGhost:masterfrom
rektide:feature-config-arg-rebased
Closed

Accept a config filename as an optional parameter to Ghost start-up.#1110
rektide wants to merge 1 commit intoTryGhost:masterfrom
rektide:feature-config-arg-rebased

Conversation

@rektide
Copy link
Contributor

@rektide rektide commented Oct 16, 2013

This feature pull-request permits a single argument to be passed into Ghost: a config filename to use, which will override the default ${appRoot}/config.js if specified.

This feature permits a single instance of Ghost to exist that any number of individual software users can use. Without this, any Ghost user needs a full checkout. For example, with this feature a sysadmin could install /opt/ghost read-only, and I could run node /opt/ghost/index /home/rektide/.config/ghost/config.js while my admin also starts node /opt/ghost/index /srv/ghost/config.js. Enabling this division between the software-package and a service's specific data is faithful to the Filesystem Hierarchy specs's division between /opt and /srv;
http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES
http://www.pathname.com/fhs/pub/fhs-2.3.html#SRVDATAFORSERVICESPROVIDEDBYSYSTEM

Briefly on implementation, this pull-request enhances config-loader's current role as a validation pass, promoting it's own exports with the values it validates. The remainder of Ghost points to the config-loader instead of having a hardcoded path to the config file.

Thank you. Please let me know if there's anything I can do to help facilitate this patch.

@bastilian
Copy link
Contributor

Would it also use a different content directory?

@rektide
Copy link
Contributor Author

rektide commented Oct 18, 2013

The database can be specified in the config file (overriding the default path.join(__dirname, '/content/data/ghost.db')), but at present images, plugins and themes directories remain hardcoded to the content folder throughout the codebase.

Good call. Switching databases was my first use case, but changing themes/style per-deploy a need too. This patch is clean and has minimal touch points: I'd very much like to see it merged, and serve as a basis for ongoing changes and discussion such as @bastilian's comments (which will require more sweeping changes). Please promote this, which will help me get started carrying these ideas along.

@ErisDS
Copy link
Member

ErisDS commented Oct 22, 2013

This is a good idea 👍 and it would be nice to see a PR for the second part (making it possible to configure the content directories) as well at some point.

Happy to get this merged in if you could please resolve the issues raised in my comments.

@ErisDS
Copy link
Member

ErisDS commented Oct 29, 2013

@rektide - Any chance you can look into updating this?

@mattwillsher
Copy link

Via an environmental var would also be useful and consistent with NODE_ENV

rektide added a commit to rektide/ghost that referenced this pull request Nov 12, 2013
rektide added a commit to rektide/ghost that referenced this pull request Nov 12, 2013
@ErisDS
Copy link
Member

ErisDS commented Nov 12, 2013

I'm not sure if this is intended for merge now as there is no comment, but please take a minute to read our guide on submitting PRs https://github.com/TryGhost/Ghost/blob/master/CONTRIBUTING.md#submitting-pull-requests particularly the part on cleaning-up history, thanks :)

rektide added a commit to rektide/ghost that referenced this pull request Nov 12, 2013
Closes TryGhost#1110.
- Promotes config-loader from a validator, to the central place where configuration state is held
- Allow config-loader two means to be told of config file to be used:
  - A preferred first argument passed into Ghost
  - A secondary GHOST_CONFIG environmental variable
- Failing to see either of the above passed in, config-loader will continue to use "config.js"
- Config-loader validates the target configuration (unchanged) & then copies that object into it's own exports
- Components needing to read configuration now require config-loader to retrieve the configuration state
- Config file continues to be loaded via require(), allowing program code to generate & export configuration, as well as simple JSON
rektide added a commit to rektide/ghost that referenced this pull request Nov 12, 2013
Closes TryGhost#1110.
- Promotes config-loader from a validator, to the central place where configuration state is held
- Allow config-loader two means to be told of config file to be used:
  - A preferred first argument passed into Ghost
  - A secondary GHOST_CONFIG environmental variable
- Failing to see either of the above passed in, config-loader will continue to use "config.js"
- Config-loader validates the target configuration (unchanged) & then copies that object into it's own exports
- Components needing to read configuration now require config-loader to retrieve the configuration state
- Config file continues to be loaded via require(): this is assumed to be a static json file
@ErisDS
Copy link
Member

ErisDS commented Nov 24, 2013

Hi, I just noticed there is a newer commit on this. Is it ready for merge? I don't get a notification for updates to a PR unless you comment so I wasn't aware any work had been done sorry 😦

@ErisDS
Copy link
Member

ErisDS commented Nov 28, 2013

Rebased and merged

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.

4 participants