This commit is contained in:
Tommy Parnell
2017-01-13 12:46:41 -05:00
parent 9d981341c0
commit 7af404cac7
13 changed files with 68 additions and 39 deletions

View File

@@ -1,13 +1,15 @@
FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app
ADD project.json project.json
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
ADD . .
EXPOSE 5000/tcp
RUN ["dotnet", "build", "-c", "Release"]
CMD ["dotnet", "run", "--server.urls", "http://*:5000"]
EXPOSE 80/tcp
CMD ["dotnet", "run", "-c", "Release", "--server.urls", "http://*:80"]

View File

@@ -8,5 +8,4 @@ RUN dotnet restore
# copy and build everything else
ADD . .
RUN dotnet build -C Release
ENTRYPOINT ["dotnet", "run", "-C", "Release"]
ENTRYPOINT ["dotnet", "run", "-c", "Release"]

View File

@@ -8,6 +8,7 @@ namespace Worker
{
public class Program
{
static Random rand = new Random();
static HttpClient httpclient = new HttpClient();
public static void Main(string[] args)
{
@@ -17,19 +18,20 @@ namespace Worker
{
while(true)
{
try
{
// try
// {
var bytes = await httpclient.GetByteArrayAsync("http://gen/8");
var results = await httpclient.PostAsync("http://hashr/hashme", new ByteArrayContent(bytes));
results.EnsureSuccessStatusCode();
var hashResults = await results.Content.ReadAsStringAsync();
var dbResult = await httpclient.GetStringAsync($"http://store/store?dt={DateTime.Now.ToString()}");
await Task.Delay(1000);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
await httpclient.GetStringAsync($"http://store/store");
await Task.Delay(rand.Next(100, 1000));
// }
// catch(Exception e)
// {
// Console.WriteLine("WORKER FAILED");
// Console.WriteLine(e.Message);
// }
}
}
}

31
docker-compose.yml Normal file
View File

@@ -0,0 +1,31 @@
version: "2"
services:
gen:
build: gen
ports:
- "8001:80"
hashr:
build: Hashr
ports:
- "8002:80"
ui:
build: ui
ports:
- "8000:80"
links:
- store
store:
build: store
ports:
- "8003:80"
worker:
build: worker
links:
- hashr
- gen
- store

View File

@@ -18,7 +18,6 @@ def index():
@app.route("/<int:how_many_bytes>")
def gen(how_many_bytes):
time.sleep(0.1)
return Response(
os.read(urandom, how_many_bytes),
content_type="application/octet-stream")

View File

@@ -1,9 +1,7 @@
FROM ruby:alpine
RUN apk add --update build-base
RUN gem install bundle
RUN gem install sinatra
RUN gem install thin
ADD Gemfile .
RUN bundle
ADD . .
CMD ["bundle", "exec", "thin", "start"]
ADD app.rb /
CMD ["ruby", "app.rb"]
EXPOSE 80

View File

@@ -1,3 +1,3 @@
source "https://rubygems.org"
gem 'sinatra'
gem 'nokogiri'
gem 'thin'

View File

@@ -1,7 +1,8 @@
require 'sinatra'
require 'date'
require 'json'
set :bind, '0.0.0.0'
set :port, 80
get '/' do
content_type :json
getData.to_json

View File

@@ -2,9 +2,9 @@ FROM node:boron-wheezy
RUN npm install -g bower
ADD package.json .
RUN npm install
ADD bower.json
RUN bower install
ADD bower.json bower.json
RUN bower install --allow-root
ADD . .
EXPOSE 3000
EXPOSE 80
CMD ["npm", "run", "start"]

View File

@@ -16,7 +16,7 @@ app.locals.ENV = env;
app.locals.ENV_DEVELOPMENT = env == 'development';
// view engine setup
app.set('port', process.env.PORT || 80);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env node
var app = require('../app');
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() {
console.log('Express server listening on port ' + server.address().port);
});

View File

@@ -9,14 +9,13 @@ router.get('/', function(req, res) {
});
router.get('/db', (req, res)=>{
// request('http://store/', function (error, response, body) {
// if (!error && response.statusCode == 200) {
// console.log(body) // Show the HTML for the Google homepage.
// }
// res.set('Content-Type', 'application/json');
// return res.send(200, body);
// })
res.json([ { date: '2017-01-01 10:01', value: 20 }, { date: '2017-01-01 11:00', value: 60 }]);
request('http://store/', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the Google homepage.
}
res.set('Content-Type', 'application/json');
return res.send(200, body);
});
});
module.exports = router;

View File

@@ -13,7 +13,7 @@
var data = []
var graph = new Rickshaw.Graph({
element: document.querySelector("#chart"),
renderer: 'line',
renderer: 'area',
series: [{
data: data,
color: 'steelblue'