Closed JeStasG closed 6 years ago
How it looks visually through prometheus+grafana: 1.Moleculer: 2.NATS: 3.At 9:58 - "pm2 restart all" and functioning restored.
In fact, servicesList is done in order to run its own set of services on each server. For example:
registry = [
{
service: "someService1.js",
server: "someServer1"
},
.....
{
service: "someService2.js",
server: "someServer2"
}
];
let servicesList = registry.filter({ server: process.env.SERVER }).map(i => i.service);
broker.loadServices(appRoot + '/services', servicesList);
Not documented (in the documentation I did not see), but through trial and error it turned out to be a working solution.
It means you reached the limit of NATS packet. By default is 1MB. You can increase it in NATS server config, but maybe you had better turn on verbose log in NATS server and check which packet is huge & reaches the limit.
Thanks, max_payload corrected and watch the result. Can you please tell me if there is a method for restarting the service without restarting the broker?
Check the hot-reload code: https://github.com/moleculerjs/moleculer/blob/master/src/service-broker.js#L605
I mean force by analogy broker.loadService. For example - broker.reloadService("service name").
@JeStasG That's exactly what the hot-reload does.
utils.clearRequireCache(service.__filename);
To clear the require.cache - so you can require the service file again - if you dont have changes then you dont need this line
then
return this.destroyService(service).then(() =>
this.loadService(service.__filename));
Destroy services do Service._stop and remove the service from the broker registry then you have a clean setup to load the service again.
Thanks!
For some reason, hotReloadService
is cached haven't tested it further but, correct source change is loaded until specifically doing a broker.stop
and reloading it..
Hello, please help! We have the following configuration ServiceBroker config.js:
Start to be made several instans by means of PM2 pm2.json:
The main script index.js:
Each service of a web.js(moleculer-web) has its own port assigned on the basis of the default port + process.env.NODE_APP_INSTANCE. With the subsequent balancing through NGINX.
Periodically falls with an error:
Please tell me where to look if the configuration NATS service in maximum payload is:
The indicated error does not appear immediately, but after 2-3 days after starting the services.