I have a Meteor method, uploadIcingaConf, wherein I use scp call from scp2 library in synchronous fashion via Meteor.wrapAsync.
I call this meteor method, uploadIcingaConf, from client side. Now the target file in scp call does not have write permission. So scp call fails. But the behavior I observe is that the scp call failure restarts the application and the function uploadIcingaConf gets called again and again in gap of about 1 minute. This keeps on repeating, application restarts and function uploadIcingaConf is called, even though no action is being done via client GUI. In-fact if I restart the application via systemctl, the function uploadIcingaConf is still called. Now this is very strange behavior in my opinion. The error being thrown by scp call is ‘throw new Error(‘handle is not a Buffer’);’.
So my question is why is function uploadIcingaConf, is getting called again and again even though application has restarted. Is this expected behavior or some bug in scp2 library.
The function uploadIcingaConf is
export const uploadIcingaConf = new ValidatedMethod({
name: 'monitoring.uploadIcingaConf',
validate: null,
run() {
if (Meteor.isServer) {
this.unblock();
/* eslint-disable global-require */
const scpClient = require('scp2');
/* eslint-enable global-require */
const icingaConfiguration = getParameter('icinga_configuration');
console.log('called ' + icingaConfiguration.configurationDirectory);
const scpSync = Meteor.wrapAsync(scpClient.scp);
scpSync('assets/app/hosts.conf', {
host: icingaConfiguration.serverName,
username: icingaConfiguration.managementUser,
privateKey: fs.readFileSync(icingaConfiguration.sshPrivateKeyPath),
path: icingaConfiguration.configurationDirectory
});
}
}
});