1.0.0 • Published 6 years ago

shellhub v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

shellhub

NPM version Build Status Coverage Status Dependency manager

An HTTP server to provide streaming ports for shell scripts, typically used for git hooks.

Features:

This project is like, uh, CGI, but much easier to install and start running.

  • URL query passed as environment variables
  • Request body piped to STDIN
  • STDOUT piped to request body

Usage

npm i -g shellhub and make a shellhubrc.json in current directory:

{
    "host": "0.0.0.0",
    "port": 8888,
    "stack": true,
    "scripts": {
        "/hello/world": {
            "cwd": "/Users/harttle/src/shellhub/demo/",
            "cmd": "hello-world.sh"
        }
    }
}

Start shellhub with default shellhubrc.json in current directory:

$ shellhub

Open http://localhost:8888/hello/world in your favorite browser, or:

curl http://localhost:8888/hello/world

The output of hello-world.sh will be streamed to stdout.

Options

NameDefaultDescription
host"localhost"The host to bind with
port8080The port to bind with
stacktrueWhether or not print stack when there's an error
scripts{}Map from pathname to shell entry, the pathname can be arbitrary string
scripts.cwdundefinedThe work directory for the shell command, resolve based on the config file
scripts.cmdundefinedThe shell command to run, which will be passed to bash -c

Q&A

Can I use a config other than ./shellhubrc.json?

$ shellhub -c path/to/your/shellhubrc.json

Where can I find the logs?

Logs are printed to STDOUT, with datetime and traceID:

[2016-11-20T14:39:25.475Z][002] PATH: /hello/world
[2016-11-20T14:39:25.475Z][002] CWD: /Users/harttle/src/shellhub/demo/
[2016-11-20T14:39:25.475Z][002] CMD: bash hello-world.sh
[2016-11-20T14:39:25.495Z][002]
[2016-11-20T14:39:25.495Z][002] STDOUT:
[2016-11-20T14:39:25.495Z][002] Hello, World!
[2016-11-20T14:39:25.495Z][002] Hi, Hell!

How to run this in background?

It's recommended to introduce a process manager like pm2.

1.0.0

6 years ago

0.4.0

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago