Reorganize main package structure per discussion
This commit is contained in:
parent
e219176e8b
commit
f8047ef8ab
3 changed files with 21 additions and 12 deletions
|
@ -64,16 +64,16 @@ Backend:
|
|||
To use an external driver, make your own package and call it something like `github.com/yourusername/chihaya`. Then, import Chihaya like so:
|
||||
|
||||
```go
|
||||
package chihaya // This is your own chihaya package.
|
||||
package main
|
||||
|
||||
import (
|
||||
c "github.com/chihaya/chihaya" // Use an alternate name to avoid the conflict.
|
||||
"github.com/chihaya/chihaya"
|
||||
|
||||
_ "github.com/yourusername/chihaya-custom-backend" // Import any of your own drivers.
|
||||
)
|
||||
|
||||
func main() {
|
||||
c.Boot() // Start Chihaya normally.
|
||||
chihaya.Boot() // Start Chihaya normally.
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by the BSD 2-Clause license,
|
||||
// which can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
package chihaya
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
@ -21,13 +21,13 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
maxprocs int
|
||||
maxProcs int
|
||||
profile string
|
||||
configPath string
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.IntVar(&maxprocs, "maxprocs", runtime.NumCPU(), "maximum parallel threads")
|
||||
flag.IntVar(&maxProcs, "maxprocs", runtime.NumCPU(), "maximum parallel threads")
|
||||
flag.StringVar(&profile, "profile", "", "if non-empty, path to write profiling data")
|
||||
flag.StringVar(&configPath, "config", "", "path to the configuration file")
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ func Boot() {
|
|||
|
||||
flag.Parse()
|
||||
|
||||
runtime.GOMAXPROCS(maxprocs)
|
||||
glog.V(1).Info("Set max threads to ", maxprocs)
|
||||
runtime.GOMAXPROCS(maxProcs)
|
||||
glog.V(1).Info("Set max threads to ", maxProcs)
|
||||
|
||||
if profile != "" {
|
||||
f, err := os.Create(profile)
|
||||
|
@ -70,7 +70,3 @@ func Boot() {
|
|||
http.Serve(cfg)
|
||||
glog.Info("Gracefully shut down")
|
||||
}
|
||||
|
||||
func main() {
|
||||
Boot()
|
||||
}
|
13
cmd/chihaya/main.go
Normal file
13
cmd/chihaya/main.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2014 The Chihaya Authors. All rights reserved.
|
||||
// Use of this source code is governed by the BSD 2-Clause license,
|
||||
// which can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/chihaya/chihaya"
|
||||
)
|
||||
|
||||
func main() {
|
||||
chihaya.Boot()
|
||||
}
|
Loading…
Add table
Reference in a new issue