Tugboat Shell (TuSH)

Attaches a terminal to the specified service. The callback includes an ID for the shell process. This ID should be used for handling stdin/stdout operations.

Arguments

  • service - Required
    The ID of the service container in which to execute the shell.

  • command - Optional
    The command to execute. If not specified, bash is executed.

  • width, height - Optional (recommended)
    If both width and height are specified, the terminal window size in the return stream is set to this size. If one, or neither, are specified, the default terminal size of 80x24 is used.

  • resize - Optional
    This is used to provide a special command to resize the terminal of an already running shell. The value for this argument must be the ID returned by the initial callback when starting the shell. In order for the resize to succeed, all three resize, width, and height arguments must be present.

  • user - Optional
    The user to execute the shell as. If not provided the default user of root will be used.

Example

socket.emit('tugboat', 'services', 'shell', args, function(err, id) {
    // Send data to stdin
    socket.emit(id, 'stdin', data);

    // Handle stdout/stderr/end
    socket.on(id, function(stream, data) {
        if (stream === 'stdout') {
            process.stdout.write(data);
        }
        if (stream === 'stderr') {
            process.stderr.write(data);
        }
        if (stream === 'end') {
            socket.disconnect();
        }
    });

    // Resize the terminal
    socket.emit('tugboat', 'services', 'shell', {
        resize: id,
        width: 110,
        height: 40,
    });
});

Output

The output from TuSH is the stdout and stderr streams directly from the shell. It also accepts data over the same stream as stdin to the shell.

Errors

  • 1016: No Services Found
    Returned if the requested service does not exist, or the requestor does not have permission to view the services' statistics.

  • 1017: No Service ID Provided
    The required service argument was not included in the request.

  • 1018: Invalid Terminal Size
    Returned if the provided width and height values do not create a valid terminal size. If returned on the initial creation of a shell, the terminal size of 80x24 will be used instead. If returned on a resize, no change will be made to the running shell.

results matching ""

    No results matching ""