go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/tree_status/main.go (about) 1 // Copyright 2023 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package main 16 17 import ( 18 "go.chromium.org/luci/grpc/prpc" 19 "go.chromium.org/luci/server" 20 "go.chromium.org/luci/server/cron" 21 "go.chromium.org/luci/server/gaeemulation" 22 "go.chromium.org/luci/server/module" 23 "go.chromium.org/luci/server/secrets" 24 spanmodule "go.chromium.org/luci/server/span" 25 "go.chromium.org/luci/server/tq" 26 27 "go.chromium.org/luci/tree_status/internal/span" 28 "go.chromium.org/luci/tree_status/internal/status" 29 pb "go.chromium.org/luci/tree_status/proto/v1" 30 "go.chromium.org/luci/tree_status/rpc" 31 32 _ "go.chromium.org/luci/server/encryptedcookies/session/datastore" 33 _ "go.chromium.org/luci/server/tq/txn/datastore" 34 ) 35 36 func main() { 37 // Additional modules that extend the server functionality. 38 modules := []module.Module{ 39 cron.NewModuleFromFlags(), 40 gaeemulation.NewModuleFromFlags(), 41 secrets.NewModuleFromFlags(), 42 tq.NewModuleFromFlags(), 43 spanmodule.NewModuleFromFlags(nil), 44 } 45 46 server.Main(nil, modules, func(srv *server.Server) error { 47 srv.ConfigurePRPC(func(s *prpc.Server) { 48 s.AccessControl = prpc.AllowOriginAll 49 // TODO(crbug/1082369): Remove this workaround once field masks can be decoded. 50 s.HackFixFieldMasksForJSON = true 51 }) 52 srv.RegisterUnaryServerInterceptors(span.SpannerDefaultsInterceptor()) 53 54 pb.RegisterTreeStatusServer(srv, rpc.NewTreeStatusServer()) 55 cron.RegisterHandler("clear-status-users", status.ClearStatusUsers) 56 return nil 57 }) 58 }