go.etcd.io/etcd@v3.3.27+incompatible/etcdmain/main.go (about) 1 // Copyright 2015 The etcd 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 etcdmain 16 17 import ( 18 "fmt" 19 "os" 20 "strings" 21 22 "github.com/coreos/go-systemd/daemon" 23 systemdutil "github.com/coreos/go-systemd/util" 24 ) 25 26 func Main() { 27 checkSupportArch() 28 29 if len(os.Args) > 1 { 30 cmd := os.Args[1] 31 if covArgs := os.Getenv("ETCDCOV_ARGS"); len(covArgs) > 0 { 32 args := strings.Split(os.Getenv("ETCDCOV_ARGS"), "\xe7\xcd")[1:] 33 rootCmd.SetArgs(args) 34 cmd = "grpc-proxy" 35 } 36 switch cmd { 37 case "gateway", "grpc-proxy": 38 if err := rootCmd.Execute(); err != nil { 39 fmt.Fprint(os.Stderr, err) 40 os.Exit(1) 41 } 42 return 43 } 44 } 45 46 startEtcdOrProxyV2() 47 } 48 49 func notifySystemd() { 50 if !systemdutil.IsRunningSystemd() { 51 return 52 } 53 sent, err := daemon.SdNotify(false, "READY=1") 54 if err != nil { 55 plog.Errorf("failed to notify systemd for readiness: %v", err) 56 } 57 if !sent { 58 plog.Errorf("forgot to set Type=notify in systemd service file?") 59 } 60 }