ssh-queue
v1.1.11
Published
Queues SSH commands to be executed one by one
Downloads
52
Readme
ssh-queue
Queues SSH commands to be executed one by one.
Created after encountering a situation where too many simultaneous connection attempts were being made to an external machine.
Wrapper for node-ssh.
Example
const sshQueue = require('ssh-queue')
// Sets params for all future connections
sshQueue.setConnectionParams({
host: HOST,
username: USERNAME,
password: PASSWORD
})
// Access the currently stored connection parameters
sshQueue.getConnectionParams()
// Queues upload of localFile to remoteFile
sshQueue.exec('upload', 'localFile', 'remoteFile')
// Queues download of remoteFile to localFile
sshQueue.exec('download', 'remoteFile', 'localFile')
// Queues execution of command
sshQueue.exec('command', 'ls')
sshQueue.exec('command', 'uptime')
sshQueue.exec('command', 'mkdir src')
// and so on, for any command
// Access the current length of the queue
let queueLength = sshQueue.getQueueLength()
sshQueue maintains a list of queued interactions with the remote machine (command executions, filePuts, and fileGets), which it works through one by one. A connection is opened when the queue becomes longer than zero, this connection is then maintained until the queue is empty again, at which point it is disposed of.
Connecting and disconnecting is handled automatically, but can be manually triggered via:
sshQueue.connect()
sshQueue.disconnect()
License
This project is licensed under the terms of MIT license. See the LICENSE file for more info.