pull-proxy
v0.0.3
Published
Git pull powered deployment solution
Downloads
5
Readme
pull-proxy
Zero downtime redeploys of websites or services pulled down from a git repo.
Works with HTTP, Websockets and raw TCP.
Usage
Create a new proxy that pulls
ghub.io from github and serves it
on port 8000
. The website's stdout and stderr will be printed on the
terminal.
var Proxy = require('pull-proxy');
var proxy = new Proxy(
'git://github.com/juliangruber/ghub.io.git',
__dirname + '/repos'
);
proxy.createManagementServer().listen(8001);
proxy.createProxyServer().listen(8000);
proxy.stdout.pipe(process.stdout);
proxy.stderr.pipe(process.stderr);
The site is served at http://localhost:8000
.
Then, when you want to redeploy, send a special request to the management server that listens on port 8001:
curl -XPUT http://localhost:8001/deploy/
You don't need to spin up a management server if redeploying is not of concern to you or you're using the JavaScript api.
Modifying checked out code
If you want to insert extra steps into the deployment process, like running
npm install
, listen to the source
event:
proxy.on('source', function (dir, done) {
var ps = spawn('npm', ['install'], { cwd: dir });
ps.once('exit', done);
});
All listeners for the source
event muss call done()
when finished.
Management interface
PUT /deploy(?branch=branch)(?remote=remote)
Redeploy, and optionally overwrite branch
, which defaults to master
, and remote
, which defaults to the remote you passed to the Proxy()
constructor.
Authentication
Authentication is basically up to you, since this only gives you a node core http server. Some easy ways would be to wrap the http server in something that does basic auth, or to make it listen on a unix socket that's only accessible via ssh.
CLI
Install with:
$ npm install -g pull-proxy
Usage:
$ pull-proxy
Git pull based deployment solution.
Usage: pull-proxy [options]
Options:
--git, -g Git url to pull from [required]
--proxy, -p Proxy port [required]
--repos, -r Path to pull repositories into [default: "./repos"]
--manage, -m Management port
--no-zero-downtime Turn of zero downtime deploys [boolean] [default: false]
--stdout, --out Forward stdout output [boolean] [default: false]
--stderr, --err Forward stderr output [boolean] [default: false]
--log, -l Print internal events on stdout [boolean] [default: false]
--help, -h Print usage instruction
Missing required arguments: git, proxy
API
Proxy(remote[, repos])
Create a new proxy that serves the repo at remote
. It will store the local
checkouts of repos in repos
, which defaults to __dirname/repos
.
Proxy#noZeroDowntime()
Turn off zero downtime deploys. This way there's always only one instance of the site running.
Proxy#createManagementServer()
Create a http server for managing the proxy.
Proxy#createProxyServer()
Create a http server that proxies requests to your site and ensures zero downtime redeploys.
Proxy#stdout, Proxy#stderr
Readable streams that contain the stdout or stderr from the spawned childprocess of the website that is being proxied to.
Proxy#deploy([{remote, branch}][,cb])
Redeploy. Optionally override remote
and branch
and get called back when
it's done.
Installation
With npm do
$ npm install pull-proxy
License
(MIT)
Copyright (c) 2013 Wayla <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.