@@ -6,21 +6,15 @@ package config
6
6
7
7
import (
8
8
"bytes"
9
- "context"
10
- "crypto/sha256"
11
9
"crypto/tls"
12
- "encoding/hex"
13
10
"encoding/json"
14
- "io"
15
11
"os"
16
- "time"
17
12
18
13
"golang.org/x/xerrors"
19
14
"google.golang.org/grpc"
20
15
"google.golang.org/grpc/credentials"
21
16
22
17
common_grpc "github.com/gitpod-io/gitpod/common-go/grpc"
23
- "github.com/gitpod-io/gitpod/common-go/log"
24
18
"github.com/gitpod-io/gitpod/ws-daemon/pkg/daemon"
25
19
)
26
20
@@ -41,63 +35,6 @@ func Read(fn string) (*Config, error) {
41
35
return & cfg , nil
42
36
}
43
37
44
- // watchConfig watches the configuration file and if changed reloads the static layer
45
- func Watch (fn string , cb func (context.Context , * daemon.Config ) error ) {
46
- hashConfig := func () (hash string , err error ) {
47
- f , err := os .Open (fn )
48
- if err != nil {
49
- return "" , err
50
- }
51
- defer f .Close ()
52
-
53
- h := sha256 .New ()
54
- _ , err = io .Copy (h , f )
55
- if err != nil {
56
- return "" , err
57
- }
58
-
59
- return hex .EncodeToString (h .Sum (nil )), nil
60
- }
61
- reloadConfig := func () error {
62
- cfg , err := Read (fn )
63
- if err != nil {
64
- return err
65
- }
66
-
67
- ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
68
- defer cancel ()
69
-
70
- return cb (ctx , & cfg .Daemon )
71
- }
72
-
73
- var (
74
- tick = time .NewTicker (30 * time .Second )
75
- oldHash string
76
- )
77
- defer tick .Stop ()
78
- for range tick .C {
79
- currentHash , err := hashConfig ()
80
- if err != nil {
81
- log .WithError (err ).Warn ("cannot check if config has changed" )
82
- }
83
-
84
- if oldHash == "" {
85
- oldHash = currentHash
86
- }
87
- if currentHash == oldHash {
88
- continue
89
- }
90
- oldHash = currentHash
91
-
92
- err = reloadConfig ()
93
- if err == nil {
94
- log .Info ("configuration was updated - reloaded static layer config" )
95
- } else {
96
- log .WithError (err ).Error ("cannot reload config - config hot reloading did not work" )
97
- }
98
- }
99
- }
100
-
101
38
type Config struct {
102
39
Daemon daemon.Config `json:"daemon"`
103
40
Service AddrTLS `json:"service"`
0 commit comments