Docker socket fix
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adam Štrauch 2022-02-07 17:12:23 +01:00
parent 676ddf2136
commit 69e46f577a
Signed by: cx
GPG Key ID: 018304FFA8988F8D
4 changed files with 15 additions and 8 deletions

View File

@ -8,7 +8,7 @@ import (
// Config keeps info about configuration of this daemon // Config keeps info about configuration of this daemon
type Config struct { type Config struct {
DockerSocket string `envconfig:"DOCKER_SOCKET" default:"unix://var/run/docker.sock"` DockerSocket string `envconfig:"DOCKER_SOCKET" default:"unix:///var/run/docker.sock"`
Token string `envconfig:"TOKEN" required:"true"` Token string `envconfig:"TOKEN" required:"true"`
AppsPath string `envconfig:"APPS_PATH" default:"/srv"` // Where applications are located AppsPath string `envconfig:"APPS_PATH" default:"/srv"` // Where applications are located
AppsBindIPHTTP string `envconfig:"APPS_BIND_IP_HTTP" default:"0.0.0.0"` // On what IP apps' HTTP port gonna be bound AppsBindIPHTTP string `envconfig:"APPS_BIND_IP_HTTP" default:"0.0.0.0"` // On what IP apps' HTTP port gonna be bound

View File

@ -68,6 +68,7 @@ func (p *Processor) waitForApp() error {
statsProcessor := StatsProcessor{ statsProcessor := StatsProcessor{
DB: p.DB, DB: p.DB,
DockerSock: p.DockerSock,
} }
for i := 0; i < loops; i++ { for i := 0; i < loops; i++ {
@ -102,6 +103,7 @@ func (p *Processor) List() (apps.Apps, error) {
statsProcessor := StatsProcessor{ statsProcessor := StatsProcessor{
DB: p.DB, DB: p.DB,
DockerSock: p.DockerSock,
} }
err := statsProcessor.GatherStates() err := statsProcessor.GatherStates()
@ -125,6 +127,7 @@ func (p *Processor) Get() (apps.App, error) {
statsProcessor := StatsProcessor{ statsProcessor := StatsProcessor{
DB: p.DB, DB: p.DB,
DockerSock: p.DockerSock,
} }
err := statsProcessor.UpdateState(p.AppName) err := statsProcessor.UpdateState(p.AppName)

View File

@ -12,6 +12,7 @@ import (
// to gather information about application containers. // to gather information about application containers.
type StatsProcessor struct { type StatsProcessor struct {
DB *gorm.DB DB *gorm.DB
DockerSock string
} }
// returns instance of getAppProcessor // returns instance of getAppProcessor
@ -34,6 +35,7 @@ func (s *StatsProcessor) UpdateUsage(name string) error {
container := docker.Container{ container := docker.Container{
App: &app, App: &app,
DockerSock: s.DockerSock,
} }
state, err := container.GetState() state, err := container.GetState()
@ -64,6 +66,7 @@ func (s *StatsProcessor) UpdateState(name string) error {
container := docker.Container{ container := docker.Container{
App: &app, App: &app,
DockerSock: s.DockerSock,
} }
state, err := container.Status() state, err := container.Status()
if err != nil { if err != nil {

View File

@ -75,6 +75,7 @@ func main() {
go func() { go func() {
statsProcessor := glue.StatsProcessor{ statsProcessor := glue.StatsProcessor{
DB: common.GetDBConnection(), DB: common.GetDBConnection(),
DockerSock: config.DockerSocket,
} }
for { for {