@@ -10,7 +10,6 @@ import (
10
10
"flag"
11
11
"net/http"
12
12
"os"
13
- "path/filepath"
14
13
"time"
15
14
16
15
"cloud.google.com/go/profiler"
@@ -21,7 +20,6 @@ import (
21
20
"golang.org/x/pkgsite/internal/config"
22
21
"golang.org/x/pkgsite/internal/dcensus"
23
22
"golang.org/x/pkgsite/internal/frontend"
24
- "golang.org/x/pkgsite/internal/localdatasource"
25
23
"golang.org/x/pkgsite/internal/log"
26
24
"golang.org/x/pkgsite/internal/middleware"
27
25
"golang.org/x/pkgsite/internal/postgres"
42
40
"for direct proxy mode and frontend fetches" )
43
41
directProxy = flag .Bool ("direct_proxy" , false , "if set to true, uses the module proxy referred to by this URL " +
44
42
"as a direct backend, bypassing the database" )
45
- localPaths = flag .String ("local" , "" , "run locally, accepts a GOPATH-like collection of local paths for modules to load to memory" )
46
- gopathMode = flag .Bool ("gopath_mode" , false , "assume that local modules' paths are relative to GOPATH/src, used only with -local" )
47
43
bypassLicenseCheck = flag .Bool ("bypass_license_check" , false , "display all information, even for non-redistributable paths" )
48
44
)
49
45
@@ -75,41 +71,36 @@ func main() {
75
71
expg := cmdconfig .ExperimentGetter (ctx , cfg )
76
72
log .Infof (ctx , "cmd/frontend: initialized cmdconfig.ExperimentGetter" )
77
73
78
- if * localPaths != "" {
79
- lds := localdatasource .New ()
80
- dsg = func (context.Context ) internal.DataSource { return lds }
74
+ proxyClient , err := proxy .New (* proxyURL )
75
+ if err != nil {
76
+ log .Fatal (ctx , err )
77
+ }
78
+
79
+ if * directProxy {
80
+ var pds * proxydatasource.DataSource
81
+ if * bypassLicenseCheck {
82
+ pds = proxydatasource .NewBypassingLicenseCheck (proxyClient )
83
+ } else {
84
+ pds = proxydatasource .New (proxyClient )
85
+ }
86
+ dsg = func (context.Context ) internal.DataSource { return pds }
81
87
} else {
82
- proxyClient , err := proxy . New ( * proxyURL )
88
+ db , err := cmdconfig . OpenDB ( ctx , cfg , * bypassLicenseCheck )
83
89
if err != nil {
84
- log .Fatal (ctx , err )
90
+ log .Fatalf (ctx , "%v" , err )
85
91
}
86
-
87
- if * directProxy {
88
- var pds * proxydatasource.DataSource
89
- if * bypassLicenseCheck {
90
- pds = proxydatasource .NewBypassingLicenseCheck (proxyClient )
91
- } else {
92
- pds = proxydatasource .New (proxyClient )
93
- }
94
- dsg = func (context.Context ) internal.DataSource { return pds }
95
- } else {
96
- db , err := cmdconfig .OpenDB (ctx , cfg , * bypassLicenseCheck )
97
- if err != nil {
98
- log .Fatalf (ctx , "%v" , err )
99
- }
100
- defer db .Close ()
101
- dsg = func (context.Context ) internal.DataSource { return db }
102
- sourceClient := source .NewClient (config .SourceTimeout )
103
- // The closure passed to queue.New is only used for testing and local
104
- // execution, not in production. So it's okay that it doesn't use a
105
- // per-request connection.
106
- fetchQueue , err = queue .New (ctx , cfg , queueName , * workers , expg ,
107
- func (ctx context.Context , modulePath , version string ) (int , error ) {
108
- return frontend .FetchAndUpdateState (ctx , modulePath , version , proxyClient , sourceClient , db )
109
- })
110
- if err != nil {
111
- log .Fatalf (ctx , "queue.New: %v" , err )
112
- }
92
+ defer db .Close ()
93
+ dsg = func (context.Context ) internal.DataSource { return db }
94
+ sourceClient := source .NewClient (config .SourceTimeout )
95
+ // The closure passed to queue.New is only used for testing and local
96
+ // execution, not in production. So it's okay that it doesn't use a
97
+ // per-request connection.
98
+ fetchQueue , err = queue .New (ctx , cfg , queueName , * workers , expg ,
99
+ func (ctx context.Context , modulePath , version string ) (int , error ) {
100
+ return frontend .FetchAndUpdateState (ctx , modulePath , version , proxyClient , sourceClient , db )
101
+ })
102
+ if err != nil {
103
+ log .Fatalf (ctx , "queue.New: %v" , err )
113
104
}
114
105
}
115
106
@@ -135,13 +126,6 @@ func main() {
135
126
log .Fatalf (ctx , "frontend.NewServer: %v" , err )
136
127
}
137
128
138
- if * localPaths != "" {
139
- lds , ok := dsg (ctx ).(* localdatasource.DataSource )
140
- if ok {
141
- load (ctx , lds , * localPaths )
142
- }
143
- }
144
-
145
129
router := dcensus .NewRouter (frontend .TagRoute )
146
130
var cacheClient * redis.Client
147
131
if cfg .RedisCacheHost != "" {
@@ -204,25 +188,3 @@ func main() {
204
188
log .Infof (ctx , "Listening on addr %s" , addr )
205
189
log .Fatal (ctx , http .ListenAndServe (addr , mw (router )))
206
190
}
207
-
208
- // load loads local modules from pathList.
209
- func load (ctx context.Context , ds * localdatasource.DataSource , pathList string ) {
210
- paths := filepath .SplitList (pathList )
211
- loaded := len (paths )
212
- for _ , path := range paths {
213
- var err error
214
- if * gopathMode {
215
- err = ds .LoadFromGOPATH (ctx , path )
216
- } else {
217
- err = ds .Load (ctx , path )
218
- }
219
- if err != nil {
220
- log .Error (ctx , err )
221
- loaded --
222
- }
223
- }
224
-
225
- if loaded == 0 {
226
- log .Fatalf (ctx , "failed to load module(s) at %s" , pathList )
227
- }
228
- }
0 commit comments