Skip to content

Instantly share code, notes, and snippets.

@jjrh
Created April 14, 2017 23:12
Show Gist options
  • Save jjrh/824e83e7743b4ee8970cfafc23af3641 to your computer and use it in GitHub Desktop.
Save jjrh/824e83e7743b4ee8970cfafc23af3641 to your computer and use it in GitHub Desktop.
reload a prosody module (or multiple modules)
var telnet = require('telnet-client');
var connection = new telnet();
var async = require('async');
var params = {
host: 'localhost',
port: 5582,
shellPrompt: '\ ',
timeout: 5500,
removeEcho: 4
};
var prosody_commands = ["module:reload(\"auth_internal_plain\", \"example.com\");" ];
connection.on('ready', function(prompt) {
console.log("ready...... sending commands\n");
async.eachSeries(prosody_commands,function(command,cb){
console.log(">",command);
connection.send(command, function(err,response){
if(err){
console.log(err);
} else {
console.log(response);
}
cb();
});
}, function(err){
console.log("all done");
connection.end();
})
});
connection.on('timeout', function() {
console.log('socket timeout!')
connection.end();
});
connection.on('close', function() {
console.log('connection closed');
});
connection.connect(params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment