Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

62 linhas
2.0KB

  1. /* ----------------------------------------------------------------------
  2. * ______ ___ __
  3. * / ____/___ / | ____ __ ___ __/ /_ ___ ________
  4. * / / __/ __ \/ /| | / __ \/ / / / | /| / / __ \/ _ \/ ___/ _ \
  5. * / /_/ / /_/ / ___ |/ / / / /_/ /| |/ |/ / / / / __/ / / __/
  6. * \____/\____/_/ |_/_/ /_/\__. / |__/|__/_/ /_/\___/_/ \___/
  7. * /____/
  8. *
  9. * (C) Copyright 2015 GoAnywhere (http://goanywhere.io).
  10. * ----------------------------------------------------------------------
  11. * Licensed under the Apache License, Version 2.0 (the "License");
  12. * you may not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS,
  19. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. * ----------------------------------------------------------------------*/
  23. package rex
  24. import (
  25. "flag"
  26. "path/filepath"
  27. "runtime"
  28. "github.com/goanywhere/rex/internal"
  29. "github.com/goanywhere/x/env"
  30. "github.com/goanywhere/x/fs"
  31. )
  32. var (
  33. options = struct {
  34. debug bool
  35. port int
  36. maxprocs int
  37. }{
  38. debug: true,
  39. port: 5000,
  40. maxprocs: runtime.NumCPU(),
  41. }
  42. )
  43. func init() {
  44. // ----------------------------------------
  45. // Project Root
  46. // ----------------------------------------
  47. var root = fs.Getcd(2)
  48. env.Set(internal.Root, root)
  49. env.Load(filepath.Join(root, ".env"))
  50. // cmd arguments
  51. flag.BoolVar(&options.debug, "debug", options.debug, "flag to toggle debug mode")
  52. flag.IntVar(&options.port, "port", options.port, "port to run the application server")
  53. flag.IntVar(&options.maxprocs, "maxprocs", options.maxprocs, "maximum cpu processes to run the server")
  54. flag.Parse()
  55. }