Closed dmitri-bazz closed 8 years ago
sorry, I can't understand your code...
I think I can explain because I have the same problem.
// Read the sftp credentials from the configuration file
var ftpConfig = JSON.parse(fs.readFileSync('./ftp.json', 'utf8'));
// Initialize gulpSSH
var gulpSSH = new plugins.ssh({
sshConfig: {
host: ftpConfig.host,
username: ftpConfig.user,
password: ftpConfig.password
}
});
gulp.task('extract-archive', function () {
return gulpSSH
.exec([
'tar xvzf ' + ftpConfig.dir + 'archive.tar.gz -C ' + ftpConfig.dir
]);
});
Let's run the task:
gulp extract-archive
It works fine, the command is executed on the remote host, I can see: [22:06:01] Finished 'extract-archive' after 1.95 s
in the console, but gulp task never ends. I can only stop it using ctrl + c
.
I tried to call process.exit()
when the end
event is fired:
gulp.task('extract-archive', function () {
return gulpSSH
.exec([
'tar xvzf ' + ftpConfig.dir + 'archive.tar.gz -C ' + ftpConfig.dir
])
.on('end', function () {
process.exit();
})
});
But this causes the following issues:
[22:13:03] Finished 'extract-archive' after 2.07 s
[22:13:04] The following tasks did not complete: extract-archive
[22:13:04] Did you forget to signal async completion?
You should use options.gulp to tell gulpSSH which gulp instance running
@zensh
Still the same. Sorry, I didn't mention that I use gulp v4. Does it make any difference?
var gulp = require('gulp');
var gulpSSH = new plugins.ssh({
sshConfig: {
host: ftpConfig.host,
username: ftpConfig.user,
password: ftpConfig.password
},
gulp: gulp
});
Would you like me to share the whole config?
I am having the same issue, using also options to pass in the gulp instance:
var gulpSsh = new GulpSsh( {
ignoreErrors: false,
sshConfig: config.deployment.toSsh,
gulp: gulp
} );
...
.pipe( gulpSsh.dest( config.deployment.toSsh.dest ) );
All works fine, but gulp never ends. Also tried (as above to use on('end'
... to finish the task, but also get the same error as above.
Any ideas, did anybody succeed?
... actually found the solution, had to close the connection properly:
...
.pipe( gulpSsh.dest( config.deployment.toSsh.dest ) )
.on('end', function() { gulpSsh.close(); });
I´m having the same Issue, neither adding the end-Listener nor adding the gulp option helped:
Code:
var gulpSSH = new GulpSSH({
ignoreErrors: false,
"gulp":gulp,
sshConfig: {
"host": "host",
"username": "username",
"port": "22",
"password": "password"
}
});
var sourcePipe = gulp
.src("C:\\myFolder\\mystuff\\**")
.pipe(gulpSSH.dest("/opt/mystuff"))
.on("end",function(){
console.log("called close");
gulpSSH.close();
});
Console log:
C:\myFolder>gulp domyStuff ... [09:19:36] gulp-ssh :: Ready [09:19:36] Preparing to write "/opt/mystuff/stuff.txt" [09:19:36] Writing '/opt/mystuff/stuff.txt' [09:19:36] Finished writing '/opt/mystuff/stuff.txt'
... nothing happens, the log line "called close" is never printed to console, need to kill the process using Ctrl+c
This is on Windows 7 connecting to a RedHat machine, but also happens on Mac-to-Unix on the same code. NodeJs 2.5.0, gulp-ssh 0.5.4
Same Issue after updating to gulp-ssh 0.5.6, unfortunately I am not able to update nodejs itself.
Hi guys:
I have refactored gulp-ssh
, v0.6.0. It works fine for me.
Please try it.
Thanks. It's works fine.
Relevant gulfile.js bit
I threw a console log in the index.js for gulp-ssh under the endStream callback to confirm that it never gets called. What's up?