Giter Club home page Giter Club logo

ukraine's Introduction

ukraine

ukraine glues haibu and node-http-proxy adding a little helper, chernobyl, that deploys into this cloud. It is probably as stable as you think it is.

https://raw.github.com/radekstepan/ukraine/master/example.png

Quick start

Make sure you have node >= 0.8.0 installed, 0.8.15 is recommended as current stable.

Install the package globally:

$ sudo npm install -g git://github.com/ohdarling/ukraine.git\#private-cloud

Create a config.json file if not present already in the lib's root:

{
    "haibu_port": 9002,
    "haibu_listen_ip": "127.0.0.1",
    "proxy_port": 8000,
    "proxy_listen_ip": "127.0.0.1",
    "proxy_host": "127.0.0.1",
    "proxy_hostname_only": false,
    "omit_haibu_port_when_hostname_only": false,
    "auth_token": ""
}
haibu_port
On which port to start the Haibu service.
haibu_listen_ip
On which ip to start the Haibu service, if use nginx as frontend this should be 127.0.0.1
proxy_port
Where will all requests go? If set to 80, you will be able to access your apps without providing a port number.
proxy_listen_ip
Proxy listen to which ip, if use nginx as frontend, it should be 127.0.0.1
proxy_host
What is the host used in the proxy routing table. This is the 'domain' you will be using to access the running apps.
auth_token
A token that a client will need to use to access the ukraine service. Leaving this property out will not require you to pass a token and is useful for debugging.
proxy_hostname_only
If set to true your apps will be routed from <app_name>.<proxy_host>:<proxy_port> instead of <proxy_host>:<proxy_port>/<app_name>/. Useful also in a case when you have links in your app that are root relative.
omit_haibu_port_when_hostname_only
If use nginx as frontend, and nginx listen to port 80, this should be true, or route in http-proxy table will contain a port and cannot match url without a port

As a server

Start it up:

$ bin/ukraine

Note

In order to run the server in the background, I recommend you install forever.js and start the service as follows:

$ sudo npm install forever -g
$ forever start bin/ukraine

On Ubuntu or Debian, there is an init script to start ukraine as a service, see server/init-script, see INSTALL.md for detail.

As a client

Move to a directory with the app to deploy. Deploy pointing to cloud instance:

$ chernobyl deploy <ukraine_ip>

Config

For setting environment variables exposed through process.env, set the key value pair env in your app's package.json file. You can also use the chernobyl app itself to pass them if you do not want to expose them in a public package.json file.

Architecture

ukraine

Spawns a node-http-proxy server that dynamically watches for changes in a routing table. All (useful) routes to haibu have been overwritten using promises.

New method for posting env vars has been added.

Token authentication per ukraine instance has been added too.

chernobyl
  1. checks that your app's package.json file is in order
  2. checks that ukraine instance is up
  3. check if we need to auth to deploy an app
  4. checks and stops an existing app if need be
  5. packs the new app and sends it to the cloud to deploy

Troubleshooting

Haibu is a poorly written piece of software, be aware of these facts:

  1. If you intend to use the API haibu exposes, be sure to send correct parameters in the right format, otherwise you will shut down the app.
  2. Your package.json start script can only include a file name, not a bash command! Haibu checks that whatever you put in there is an existing file. Even more annoyingly, the file needs to be a js file that node can call.
  3. Sometimes zlib complains when streaming a package, the code here attempts to keep packing and streaming apps to deploy if it gets these errors.
  4. Uploading a new version of the app would not necessarily invalidate the old version, thus we brutforce remove the previous apps.
  5. When an app is deployed, it might still take a second or two for it to actually show over the proxy server.
  6. Although it should be allowed, haibu only allows to kill an app by its name, not name and username so we all deploy apps into a chernobyl namespace and if you want to deploy the same app again on a different port, you need to change its name in config.json.
  7. Restarting the app does not work as one would expect getting the latest env variables, stopping does not either expecting an application object instead of the name it is passed from the service. When setting new environment variable, then, we take a custom approach of stopping a running instance, getting the latest hash of its package and starting it again with these settings.

That is why we use our own version of it since v0.12.0

ukraine's People

Contributors

radekstepan avatar ohdarling avatar

Watchers

James Cloos avatar

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.