Giter Site home page Giter Site logo

docker-exec-websocket-client's Introduction

docker-exec-websocket-client

Purpose

Client for docker-exec-websocket-server.

Usage

Client:

var DockerClient = require('../lib/client.js');
var client = new DockerClient({
  url: 'ws://localhost:8081/a' //whole url of websocket, preface with wss if secure
  tty: 'true', //Whether or not we expect VT100 style output, also enables exit codes
  command: '/bin/bash', //Command to be run, can be an array with options such as ['cat', '-E']
  wsopts: {}, //Pass in websocket options for the underlying websocket
});
await client.execute();
process.stdin.pipe(client.stdin);
client.stdout.pipe(process.stdout);
client.stderr.pipe(process.stderr);
client.on('exit', (exitCode) => {
  //exitCode is a number between 0 and 255
  process.exit(exitCode);
});

There are also other client events:

  • open signifies the opening of the websocket
  • pause and resume signify when the server has paused/resumed sending data
  • shutdown signifies the server was shut down
  • error signifies that some sort of internal error occured, and may carry a utf-8 payload

Testing

Ensure Docker is installed.

To test locally:

  • Run yarn install to install the dependencies, including developer dependencies
  • Run yarn test
  • You can pass environment variables and commands to mocha as well, such as DEBUG=* yarn test -f 'docker exec wc'

To test with docker-compose, similar to CI:

  • Run docker-compose build --build-arg NODE_VERSION=16-bullseye, or change to the desired Node.js image tag
  • Run docker-compose run --rm test
  • Repeat docker-compose build ... when the code changes or you want to try a different Node.js image.

docker-exec-websocket-client's People

Contributors

baygeldin avatar ccooper avatar dependabot[bot] avatar djmitche avatar eggylv999 avatar eliperelman avatar imbstack avatar jonasfj avatar jwhitlock avatar lotas avatar petemoore avatar reznord avatar walac avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

jwhitlock

docker-exec-websocket-client's Issues

"docker exec wc -c" test fails with Node.js v16.13.2

This test take 45ms on Node.js v14.17.5, but fails with a timeout on Node.js v16.13.2:

test('docker exec wc -c', async () => {

Test output:

    1) docker exec wc -c
    ✓ cat on server (512ms)
    ✓ exit code (504ms)
    ✓ connection limit
    ✓ automatic pausing (1008ms)
    ✓ session count
    ✓ resize (3513ms)


  6 passing (48s)
  1 failing

  1) trying client
       docker exec wc -c:
     Error: Timeout of 40000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/john/src/docker-exec-websocket-client/test/test.js)
      at listOnTimeout (node:internal/timers:557:17)
      at processTimers (node:internal/timers:500:7)

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.