Merge pull request #82 from leandrofars/dev
Docker + api increase timeout
This commit is contained in:
commit
29b308987c
|
|
@ -81,8 +81,8 @@ func StartApi(a Api) {
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Addr: "0.0.0.0:" + a.Port,
|
Addr: "0.0.0.0:" + a.Port,
|
||||||
// Good practice to set timeouts to avoid Slowloris attacks.
|
// Good practice to set timeouts to avoid Slowloris attacks.
|
||||||
WriteTimeout: time.Second * 30,
|
WriteTimeout: time.Second * 60,
|
||||||
ReadTimeout: time.Second * 30,
|
ReadTimeout: time.Second * 60,
|
||||||
IdleTimeout: time.Second * 60,
|
IdleTimeout: time.Second * 60,
|
||||||
Handler: corsOpts.Handler(r), // Pass our instance of gorilla/mux in.
|
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)
|
delete(a.MsgQueue, msg.Header.MsgId)
|
||||||
log.Println("requests queue:", a.MsgQueue)
|
log.Println("requests queue:", a.MsgQueue)
|
||||||
getMsgAnswer = msg.Body.GetResponse().GetGetResp()
|
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)
|
log.Printf("Request %s Timed Out", msg.Header.MsgId)
|
||||||
w.WriteHeader(http.StatusGatewayTimeout)
|
w.WriteHeader(http.StatusGatewayTimeout)
|
||||||
delete(a.MsgQueue, msg.Header.MsgId)
|
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)
|
log.Println("requests queue:", a.MsgQueue)
|
||||||
json.NewEncoder(w).Encode(msg.Body.GetResponse().GetGetResp())
|
json.NewEncoder(w).Encode(msg.Body.GetResponse().GetGetResp())
|
||||||
return
|
return
|
||||||
case <-time.After(time.Second * 30):
|
case <-time.After(time.Second * 40):
|
||||||
log.Printf("Request %s Timed Out", msg.Header.MsgId)
|
log.Printf("Request %s Timed Out", msg.Header.MsgId)
|
||||||
w.WriteHeader(http.StatusGatewayTimeout)
|
w.WriteHeader(http.StatusGatewayTimeout)
|
||||||
delete(a.MsgQueue, msg.Header.MsgId)
|
delete(a.MsgQueue, msg.Header.MsgId)
|
||||||
|
|
|
||||||
74
devops/docker-compose.yaml
Normal file
74
devops/docker-compose.yaml
Normal file
|
|
@ -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
|
||||||
Loading…
Reference in New Issue
Block a user