Giter VIP home page Giter VIP logo

webexec's Introduction

webexec

Webexec makes it easy to build a web interface for linux commands. Simply define your shell command and arguments and webexec builds a web page with a form and websocket endpoint that lets you run the command and stream its output from a web browser. You can also pause and resume a command (using SIGSTOP and SIGCONT) from the web interface.

screenshot

Setup

The webexec module exports a connectHandler function that instantiates a websocket connect handler function for use with the ws websocket library:

connectHandler: function(name, command, options)
  • name (string) is your command's name for display purposes
  • command is an array of strings or objects making up your command
    • strings are fixed parts of the command per child_process.spawn args
    • objects of the form {name: '(field name)'} become text fields in the UI whose string value is inserted here
    • objects of the form {name: '(field name)', options: [{name: '(name)', value: '(value)'}, ...]} become select fields whose string value is inserted here
  • options is an optional object with the following keys and default values:
    • cwd (string), provided to child_process.spawn, defaults to client script's own working directory
    • maxLogLength (number), in characters, of program output to store in memory; defaults to 10000

Here's an example generating a connect handler for a command that tails server logs:

var onConnect = require('webexec').connectHandler('Server Logs', [
  'tail', '-F', {
    name: 'Log',
    options: [
      {name: 'Access', value: '/var/log/nginx/access.log'},
      {name: 'Error', value: '/var/log/nginx/error.log'}
    ]
  }
]);

In addition to attaching the websocket connect handler to a ws.WebSocketServer object, you must serve the UI front-end index.html via http. The javascript on that page will connect to the websocket endpoint at the same host and path.

See server.js for a complete example of a standalone webexec server. You can launch this server by running npm start in the project directory.

webexec's People

Contributors

kganser avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

triplekill

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.