main.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. package etcdmain
  15. import (
  16. "fmt"
  17. "os"
  18. "github.com/coreos/go-systemd/daemon"
  19. systemdutil "github.com/coreos/go-systemd/util"
  20. )
  21. func Main() {
  22. checkSupportArch()
  23. if len(os.Args) > 1 {
  24. switch os.Args[1] {
  25. case "gateway", "grpc-proxy":
  26. if err := rootCmd.Execute(); err != nil {
  27. fmt.Fprint(os.Stderr, err)
  28. os.Exit(1)
  29. }
  30. return
  31. }
  32. }
  33. startEtcdOrProxyV2()
  34. }
  35. func notifySystemd() {
  36. if !systemdutil.IsRunningSystemd() {
  37. return
  38. }
  39. sent, err := daemon.SdNotify(false, "READY=1")
  40. if err != nil {
  41. plog.Errorf("failed to notify systemd for readiness: %v", err)
  42. }
  43. if !sent {
  44. plog.Errorf("forgot to set Type=notify in systemd service file?")
  45. }
  46. }