Skip to content

Commit

Permalink
Dockerfile added, some minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hypersleep committed May 26, 2016
1 parent a24696b commit 4911052
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Torchfile
Torchfile
torch
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.6.2-wheezy
MAINTAINER Vladislav Spirenkov <moiplov@gmail.com>

# Install system dependencies
RUN apt-get update -qq && \
apt-get install -qq -y pkg-config build-essential

RUN mkdir -p /app
WORKDIR /app
COPY . /app/
ENV GOPATH /go/
RUN go get -d -v
RUN go build -o torch

CMD ["./torch"]
15 changes: 5 additions & 10 deletions torchfile.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import(
"time"
"bufio"
"os/exec"
"errors"
Expand All @@ -17,7 +18,7 @@ type Torchfile struct {
}

func (torchfile Torchfile) Run() error {
torchfile.logChan = make(chan []byte)
torchfile.logChan = make(chan []byte, 1024)
torchfile.errChan = make(chan error)

switch torchfile.ProducerType {
Expand Down Expand Up @@ -49,11 +50,7 @@ func (torchfile Torchfile) exec() {
go func(){
for {
r := bufio.NewReader(stdout)
line, _, err := r.ReadLine()
if err != nil {
torchfile.errChan <- err
return
}
line, _, _ := r.ReadLine()
torchfile.logChan <- line
}
}()
Expand All @@ -62,10 +59,6 @@ func (torchfile Torchfile) exec() {
for {
r := bufio.NewReader(stderr)
line, _, _ := r.ReadLine()
if err != nil {
torchfile.errChan <- err
return
}
torchfile.logChan <- line
}
}()
Expand All @@ -78,6 +71,8 @@ func (torchfile Torchfile) exec() {

err = cmd.Wait()
if err != nil {
// wait for stdout and stderr
time.Sleep(5 * time.Second)
torchfile.errChan <- err
return
}
Expand Down

0 comments on commit 4911052

Please sign in to comment.