Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Support external config files #2163

Closed
bettimms opened this issue May 10, 2018 · 5 comments
Closed

Support external config files #2163

bettimms opened this issue May 10, 2018 · 5 comments

Comments

@bettimms
Copy link

bettimms commented May 10, 2018

I was playing with a project to generate multiple config files based on currency and strategy and I didn't want to "pollute" gekko project with custom files. What I was trying to do is feed gekko with config file and start it from a different project(location) and seems it's not supported because of this part of the code in core/util.js:

// helper functions
var util = {
  getConfig: function() {
    // cache
    if(_config)
      return _config;

    if(!program.config)
        util.die('Please specify a config file.', true);

    if(!fs.existsSync(util.dirs().gekko + program.config))
      util.die('Cannot find the specified config file.', true);

    _config = require(util.dirs().gekko + program.config);
    return _config;
  },
...

Current code supports only config files located within gekko folder!

I'd propose to support both cases so config file can be provided from within gekko project or external path. Making this small change could make it more flexible and support cases like mine where you don't want to make changes directly in gekko project but adding features from external projects:

// helper functions
var util = {
  getConfig: function() {
    // cache
    if (_config)
      return _config;

    if (!program.config)
      util.die('Please specify a config file.', true);

    try {
      _config = require(program.config);
      return _config;
    }
    catch (e) {
      if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
        _config = require(util.dirs().gekko + program.config);
        return _config;
      }
      else
        util.die('Cannot find the specified config file.', true);
    }
  },

So we could start gekko also like so:

node /path/to/gekko/gekko --config /path/to/config.js

I could make a PR if needed!

UPDATE: This method supports current cli method and the method I suggested. It’ll not remove current option!

@Dalekxy
Copy link
Contributor

Dalekxy commented May 16, 2018

I think the current option is more convenient. Why isn't it possible to create a config folder in your gekko/ folder?
then you can start cli with "node gekko -c config/config.js"

@bettimms
Copy link
Author

bettimms commented May 16, 2018

This suggestion will not remove current option, it will just extend it to support external configs. It works to generate inside gekko and that’s how I initially started, but I had a copy of gekko in source control and these config files might change frequently to monitor currencies based on their performance. Every time i was generating configs, package.json was changing and also files there, so I didn't want to make direct changes in gekko folder in order to continue and be able to get latest updates from gekko. This way i build multi-gekko as external tool that will not affect gekko(well currently yes because of this util.js). So making it external gave me the option to not make commits for every change of asset or strategy and kept gekko clean, while on the other side multi-gekko can scale independently from gekko.

@askmike
Copy link
Owner

askmike commented May 18, 2018

Yes this is a big issue. Even though most modules inside Gekko are modular and independent of each other most files still import util which requires a config. That came out of a time when the whole codebase was very small and this was managable.

Here is an example of a huge part of the codebase that I am completely pulling out of these weird dependencies: #2118

Going forward I want to do that for a lot more modules.


Quick question: what kind of code are you looking to use outside Gekko?

@bettimms
Copy link
Author

bettimms commented May 18, 2018

As I explained in previous comment, I was building this dynamic config generator to make it easier to monitor multiple assets and currencies with multiple strategies. You may have a look at multi-gekko, that's the case I had! Initially i started as everyone, just dropping my files inside gekko folder but then I had two machines and I had to commit changes very frequently to reflect on the other one. I ignored configs folder that was being generated but I didn't like that project.json of gekko was changing, so I decided to make a small change in util.js and make external the project(multi-gekko).

@stale
Copy link

stale bot commented Oct 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you feel this is very a important issue please reach out the maintainer of this project directly via e-mail: gekko at mvr dot me.

@stale stale bot added the wontfix label Oct 24, 2018
@stale stale bot closed this as completed Nov 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants