Api Server - The oracle of the dyno world
The apiserver is the central server and API endpoint for OpenRuko, it is written in Node.js and uses PostgreSQL to persist state. It exposes methods via a restful API to query and manipulate the state of the system, dyno hosts call in periodically to pick up jobs which we try to distribute fairly by holding on to each request for a small amount of time in order to determine the least burden dyno node. The API tries to aims to be compatible with Heroku client tools, and whilst certain features such as addons, ssl certs aren't support this is an ongoing effort.
Tested on Linux 3.2 using node 0.8 and postgreSQL 9.1.
On a fresh Ubuntu 12.04 LTS instance:
https://help.ubuntu.com/community/PostgreSQL (after installing, createdb root is handy)
apt-get install postgresql postgresql-client postgresql-server-dev-9.1 apt-get install postgresql-contrib-9.1 # required for pycrypto hstore etc.. apt-get install uuid-dev # required by node-uuid apt-get install python-software-properties
Node.js 0.8.x is not available in available Ubuntu repositories, however Chris Lea provides a PPA that works very well, following the instructions onsite adding the relevant lines to /etc/apt/sources.list
add-apt-repository ppa:chris-lea/node.js apt-get update apt-get install nodejs npm
Please share experiences with CentOS, Fedora, OS X, FreeBSD etc...
git clone https://github.com/openruko/apiserver.git apiserver cd apiserver
Install node.js dependencies:
Create an ssh key
ssh-keygen -t rsa
sudo -u postgres createuser -s -P -U postgres # enter your login name # enter the password, for exemple openruko createdb openruko
Create certs for the rendezvous endpoint (tls):
apiserver/bin/apiserver will check for the presence of several environment variables, these must be configured as part of the process start - e.g. configured in supervisord or as part of boot script see ./apiserver/conf.js
- APISERVER_KEY - special key for other services to authenticate with API server (you can generate one with
- PG_USER - Your login name, unless you set something else.
- PG_PASSWORD - Your postgresql password, for exemple openruko
- S3_KEY - You need an Amazon S3 account to store repos and slug archive
- S3_SECRET - You need an Amazon S3 account to store repos and slug archive
- S3_BUCKET - You need an Amazon S3 account to store repos and slug archive
If you don't want to use Amazon S3, you could use a clone like fakes3. Just add the following environment variable:
- S3_HOSTNAME - If yout host an S3 clone on your machine use mymachine.me in place of localhost.
- S3_PORT - The S3 clone listening port.
$ cat > .env << EOF APISERVER_KEY=xxx PG_PASSWORD=xxx S3_KEY=xxx S3_SECRET=xxx S3_BUCKET=xxx EOF foreman start
Create a user
Once apiserver launched, you will need to create your first user.
createdb openruko_test PG_PASSWORD=xxx npm test
Help and Todo
Loads to do on this part, not limited to:
Improve setup scripts and find a path to database migrations.
In updatestate handle logic to handle failed instance, retries, and kills - if dyno is not consistent with state in database.
apiserver and other openruko components are licensed under MIT.