Giter Club home page Giter Club logo

Comments (10)

stefanwalther avatar stefanwalther commented on July 26, 2024 2

... actually found the solution, had to close the connection properly:

...
    .pipe( gulpSsh.dest( config.deployment.toSsh.dest ) )
    .on('end', function() { gulpSsh.close(); });

from gulp-ssh.

zensh avatar zensh commented on July 26, 2024

sorry, I can't understand your code...

from gulp-ssh.

wujekbogdan avatar wujekbogdan commented on July 26, 2024

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?

from gulp-ssh.

zensh avatar zensh commented on July 26, 2024

You should use options.gulp to tell gulpSSH which gulp instance running

from gulp-ssh.

wujekbogdan avatar wujekbogdan commented on July 26, 2024

@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?

from gulp-ssh.

stefanwalther avatar stefanwalther commented on July 26, 2024

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?

from gulp-ssh.

AGoliath avatar AGoliath commented on July 26, 2024

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

from gulp-ssh.

AGoliath avatar AGoliath commented on July 26, 2024

Same Issue after updating to gulp-ssh 0.5.6, unfortunately I am not able to update nodejs itself.

from gulp-ssh.

zensh avatar zensh commented on July 26, 2024

Hi guys:
I have refactored gulp-ssh, v0.6.0. It works fine for me.
Please try it.

from gulp-ssh.

wujekbogdan avatar wujekbogdan commented on July 26, 2024

Thanks. It's works fine.

from gulp-ssh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.