A simple HTTP server to invoke shell scripts, typically used for git hooks.
npm install shellhub



An HTTP server to provide streaming ports for shell scripts, typically used for git hooks.
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
npm i -g shellhub and make a shellhubrc.json in current directory:
``json`
{
"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:
`bash`
$ shellhub
Open http://localhost:8888/hello/world in your favorite browser, or:
`bash`
curl http://localhost:8888/hello/world
The output of hello-world.sh will be streamed to stdout.
Name | Default | Description
--- | --- | ---
host | "localhost" | The host to bind withport | 8080 | The port to bind withstack | true | Whether or not print stack when there's an errorscripts | {} | Map from pathname to shell entry, the pathname can be arbitrary stringscripts.cwd | undefined | The work directory for the shell command, resolve based on the config filescripts.cmd | undefined | The shell command to run, which will be passed to bash -c
`bash`
$ shellhub -c path/to/your/shellhubrc.json
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!
It's recommended to introduce a process manager like [pm2][pm2].
[pm2]: https://github.com/Unitech/pm2