Fixed builds, added metric output.

This commit is contained in:
Travis Reeder
2016-06-16 19:32:12 -07:00
parent 222c434fa2
commit 60db6e1d51
7 changed files with 111 additions and 73 deletions

View File

@@ -14,6 +14,8 @@ Now add routes to the app. First we'll add a route to the output of a docker con
curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello.rb","image":"treeder/hello.rb", "type":"run"}' http://localhost:8080/test/1/projects/123/apps/myapp/routes
```
curl -H "Content-Type: application/json" -X POST -d '{"path":"/helloiron","image":"iron/hello", "type":"run"}' http://localhost:8080/test/1/projects/123/apps/myapp/routes
Test out the route:
```sh
@@ -44,27 +46,27 @@ And test it out:
curl -i -X GET http://localhost:8080/sinatra?app=myapp
```
You'all also get a custom URL like this when in production.
```
appname.projectid.iron.computer
```
## Building/Testing
```sh
dj go build
docker run -e "IRON_TOKEN=GP8cqlKSrcpmqeR8x9WKD4qSAss" -e "IRON_PROJECT_ID=4fd2729368a0197d1102056b" --rm -it --privileged --net=host -v "$PWD":/app -w /app -p 8080:8080 treeder/go-dind sh -c 'rc default && ./app'
```
Then run the commands above to use it.
Build image:
Build:
```sh
docker build -t iron/gateway:latest .
# one time:
glide install
# then every time
./build.sh
```
Test it, the iron token and project id are for cache.
```sh
docker run -e "IRON_TOKEN=GP8cqlKSrcpmqeR8x9WKD4qSAss" -e "IRON_PROJECT_ID=4fd2729368a0197d1102056b" --rm -it --privileged --net=host -p 8080:8080 iron/gateway
docker run -e "IRON_TOKEN=GP8cqlKSrcpmqeR8x9WKD4qSAss" -e "IRON_PROJECT_ID=4fd2729368a0197d1102056b" --rm -it --privileged -p 8080:8080 iron/gateway
```
Push it:
@@ -80,61 +82,3 @@ After deploying, running it with:
```sh
docker run -e "IRON_TOKEN=GP8cqlKSrcpmqeR8x9WKD4qSAss" -e "IRON_PROJECT_ID=4fd2729368a0197d1102056b" --name irongateway -it --privileged --net=host -p 8080:8080 -d --name irongateway iron/gateway
```
# Previous version:
## What's going on?
- worker.rb connects to router and adds routes.
- client.rb connects to router which checks the routing table, proxies the request to one of the destinations and returns the response.
The idea here is that IronWorker backend can tell the router that it started a process and to start routing requests.
## Usage
```
iron worker upload --name hello-sinatra --host YOURHOST treeder/hello-sinatra
```
Then hit the url:
```
http://router.iron.io/?rhost=YOURHOST
```
## Todo
This is just a simple prototype. To get to production would need:
- Ability to start new workers based on some auto scaling scheme.
- Authentication (same as always).
## Testing for reals on staging
### 1) Deploy router
Using DockerJockey:
```
dj run --on aws -i --name router -v "$(pwd)":/app -w /app -p 80:8080 treeder/golang-ubuntu:1.3.3on14.04 ./router
```
### 2) Update DNS
Update DNS entry `router.iron.io` to point to the newly launched server after dj deploy.
Or SimpleDeployer:
- start router.go on remote server (there's a test project on SD already:
- http://www.simpledeployer.com/projects/ea129e74-52fa-11e2-a91a-12313d008ea2/servers
- this is on aws+sandbox@iron.io account
- go build ./src/router; sudo ./router
- iron_worker upload -e staging --project-id 515b657bc731ff1e69000917 --host routertest-staging.irondns.info sinatra
- visit http://routertest.iron.io (or ruby client.rb)
- BOOM!
## Deploying to production
- just deploy as normal from SD project
- use routertest.irondns.info for host