diff --git a/backend/services/controller/internal/api/api.go b/backend/services/controller/internal/api/api.go index 1fa9987..2f53cb2 100644 --- a/backend/services/controller/internal/api/api.go +++ b/backend/services/controller/internal/api/api.go @@ -81,8 +81,8 @@ func StartApi(a Api) { srv := &http.Server{ Addr: "0.0.0.0:" + a.Port, // Good practice to set timeouts to avoid Slowloris attacks. - WriteTimeout: time.Second * 30, - ReadTimeout: time.Second * 30, + WriteTimeout: time.Second * 60, + ReadTimeout: time.Second * 60, IdleTimeout: time.Second * 60, Handler: corsOpts.Handler(r), // Pass our instance of gorilla/mux in. } @@ -181,7 +181,7 @@ func (a *Api) deviceFwUpdate(w http.ResponseWriter, r *http.Request) { delete(a.MsgQueue, msg.Header.MsgId) log.Println("requests queue:", a.MsgQueue) getMsgAnswer = msg.Body.GetResponse().GetGetResp() - case <-time.After(time.Second * 30): + case <-time.After(time.Second * 40): log.Printf("Request %s Timed Out", msg.Header.MsgId) w.WriteHeader(http.StatusGatewayTimeout) delete(a.MsgQueue, msg.Header.MsgId) @@ -441,7 +441,7 @@ func (a *Api) deviceGetMsg(w http.ResponseWriter, r *http.Request) { log.Println("requests queue:", a.MsgQueue) json.NewEncoder(w).Encode(msg.Body.GetResponse().GetGetResp()) return - case <-time.After(time.Second * 30): + case <-time.After(time.Second * 40): log.Printf("Request %s Timed Out", msg.Header.MsgId) w.WriteHeader(http.StatusGatewayTimeout) delete(a.MsgQueue, msg.Header.MsgId) diff --git a/devops/docker-compose.yaml b/devops/docker-compose.yaml new file mode 100644 index 0000000..2149524 --- /dev/null +++ b/devops/docker-compose.yaml @@ -0,0 +1,74 @@ +services: + + oktopustr369: + image: 'golang:1.18' + container_name: oktopustr369 + tty: true + stdin_open: true + volumes: + - ../:/app/oktopus + command: bash -c "cd /app/oktopus/backend/services/controller && go run cmd/oktopus/main.go -mongo mongodb://mongodb:27017 -a mochi -p 1883" + ports: + - 8000:8000 + depends_on: + - mongodb + - mochi + networks: + - usp_network + + mongodb: + image: mongo + container_name: mongodb + networks: + - usp_network + + redis: + image: redis + container_name: redis + networks: + - usp_network + + mochi: + image: 'golang:1.18' + container_name: mochi + tty: true + stdin_open: true + volumes: + - ../:/app/oktopus + command: bash -c "cd /app/oktopus/backend/services/mochi/cmd/ && go run main.go -redis 'redis:6379'" + ports: + - 1883:1883 + depends_on: + - redis + networks: + - usp_network + + socketio: + image: 'node:14.20' + container_name: socketio + tty: true + stdin_open: true + volumes: + - ../:/app/oktopus + command: bash -c "cd /app/oktopus/backend/services/socketio/ && npm i && node server.js" + ports: + - 5000:5000 + networks: + - usp_network + + frontend: + image: 'node:14.20' + container_name: frontend + tty: true + stdin_open: true + volumes: + - ../:/app/oktopus + command: bash -c "cd /app/oktopus/frontend && npm i && npm run dev" + ports: + - 3000:3000 + networks: + - usp_network + +networks: + usp_network: + driver: bridge