moleculerjs / moleculer-cli

:herb: Command line tool for Moleculer
http://moleculer.services/docs/moleculer-cli.html
MIT License
48 stars 28 forks source link

REPL cache commands/configuration not working #56

Closed bbmarkus closed 2 years ago

bbmarkus commented 2 years ago

I have a configuration file that specifies an in memory cacher (tried both cacher true and with options), yet the service broker never has any cacher active.

info shows that the config loaded is correct, i.e. cacher is true, but it also shows in the broker section that cacher is none, what am I missing here? Obviously the cache commands then complain about there being no cacher.

    Node version             : v12.22.8
    Moleculer version        : 0.14.19
    Protocol version         : 4

---

    Namespace                : <None>
    Node ID                  : cli-desktop-po9k7n1-32464
    Services                 : 1
    Actions                  : 7
    Events                   : 0

    Strategy                 : RoundRobinStrategy
    Cacher                   : <None>
    Nodes                    : 2

---

    default
      namespace              : ""
      metadata
      logger
        type                 : "Console"
      logLevel               : "info"
      cacher                 : true
      serializer             : "JSON"
      requestTimeout         : 10000
      .....
AndreMaz commented 2 years ago

Hi @bbmarkus can you create a repro repo please?

icebob commented 2 years ago

It looks like your moleculer.config.js is wrong. There is no "default" property in the config file.

bbmarkus commented 2 years ago

@icebob the config is passed through typescript, so the default is probably because of that, however, it does work for the actual node running the microservices just fine the config gets picked up correctly there 🤔

So is it the case that I need to use different config files for cli and the actual microservices?

bbmarkus commented 2 years ago

In case someone bumps into similar issue, the fix was simply changing export default brokerConfig; to export = brokerConfig; in the typescript file.

I guess the config was never working to begin with, although we certainly never noticed this before 🤦.

bbmarkus commented 2 years ago

Turns out moleculer-runner has support for export default in typescript files, when turned to commonjs modules, so made a patch to make the file loading behaviour same between the two components @icebob