teambition / gulp-ssh

SSH and SFTP tasks for gulp
184 stars 38 forks source link

shell commands hang, I can't see errors #74

Closed ernie58 closed 6 years ago

ernie58 commented 6 years ago

Hi,

I'm trying to execute some bash scripts on a remote after uploading a tar-file. The upload works. The shell commands are printed to my terminal but nothing happens. There are no errors in the debug.log file. The script doesn't exit, and I don't see any errors.

This is my code. Am I doing something wrong here?

//execute bash script
gulp.task('deploy', ['upload'], function(){
    return ssh.shell([
        'cd ' + deployTargetLocation, 
        'rm -R -v app', 
        'rm -R -v public/cache', 
        'rm -R -v public/font', 
        'rm -R -v public/images', 
        'rm -R -v public/preview/EP', 
        'rm -R -v public/scripts', 
        'rm -R -v public/styles', 
        'rm -R -v bootstrap', 
        'tar -xvzf at.tar.gz', 
        'rm -v at.tar.gz', 
        'chmod -R 777 app/storage', 
        'chown -R apache:apache app/', 
        'chown -R apache:apache public/', 
        'chown -R apache:apache bootstrap/', 
        'composer self-update', 
        'composer update', 
        'chown -R apache:apache bootstrap/'
        ],
        { filePath: 'debug.log' }
    ).pipe(gulp.dest('debug.log'));
});

//upload tar and bash-script
gulp.task('upload', function(){
    return gulp.src(["build.tar.gz"]).pipe(ssh.dest(deployTargetLocation ));
});

This is the output for the commands:


[19:07:30] gulp-ssh :: shell :: cd /usr/share/nginx

[19:07:30] gulp-ssh :: shell :: rm -R -v app

[19:07:30] gulp-ssh :: shell :: rm -R -v public/cache

[19:07:30] gulp-ssh :: shell :: rm -R -v public/font

[19:07:30] gulp-ssh :: shell :: rm -R -v public/images

[19:07:30] gulp-ssh :: shell :: rm -R -v public/preview/EP

[19:07:30] gulp-ssh :: shell :: rm -R -v public/scripts

[19:07:30] gulp-ssh :: shell :: rm -R -v public/styles

[19:07:30] gulp-ssh :: shell :: rm -R -v bootstrap

[19:07:30] gulp-ssh :: shell :: tar -xvzf at.tar.gz

[19:07:30] gulp-ssh :: shell :: rm -v at.tar.gz

[19:07:30] gulp-ssh :: shell :: chmod -R 777 app/storage

[19:07:30] gulp-ssh :: shell :: chown -R apache:apache app/

[19:07:30] gulp-ssh :: shell :: chown -R apache:apache public/

[19:07:30] gulp-ssh :: shell :: chown -R apache:apache bootstrap/

[19:07:30] gulp-ssh :: shell :: composer self-update

[19:07:30] gulp-ssh :: shell :: composer update

[19:07:30] gulp-ssh :: shell :: chown -R apache:apache bootstrap/
mojavelinux commented 6 years ago

It looks like perhaps the shell isn't responding to or honoring the exit command.

Could you add onto the chain of your shell command:

.on('ssh2Data', (data) => console.dir(data.toString()))

That should allow you to see how the server is responding to each command.

ernie58 commented 6 years ago

@mojavelinux works like a charm! Server expected a y/n input. Thx!

mojavelinux commented 6 years ago

Nice!

mojavelinux commented 6 years ago

I added a warning to the README about this. See #85.