Skip to content

Commit 81aeb71

Browse files
authored
Merge pull request #167 from Fenny/master
Fix flag redefined
2 parents 653e0f0 + 50fc3f1 commit 81aeb71

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ os:
55
- windows
66
- osx
77
go:
8-
- 1.13.x
8+
- 1.11.x
99
env:
1010
- GO111MODULE=on
1111
install:

app.go

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,19 @@ type (
7070
}
7171
)
7272

73-
var prefork, child bool
74-
75-
func regBoolVar(p *bool, name string, value bool, usage string) {
76-
if flag.Lookup(name) == nil {
77-
flag.BoolVar(p, name, value, usage)
78-
}
79-
}
80-
func getBoolFlag(name string) bool {
81-
return flag.Lookup(name).Value.(flag.Getter).Get().(bool)
82-
}
83-
func init() {
84-
regBoolVar(&prefork, "prefork", false, "use prefork")
85-
regBoolVar(&child, "child", false, "is child process")
86-
}
73+
var prefork = flag.Bool("fiber-prefork", false, "use prefork")
74+
var child = flag.Bool("fiber-child", false, "is child process")
8775

8876
// New ...
8977
func New(settings ...*Settings) (app *App) {
9078
flag.Parse()
91-
prefork = getBoolFlag("prefork")
92-
child = getBoolFlag("child")
93-
9479
app = &App{
95-
child: child,
80+
child: *child,
9681
}
9782
if len(settings) > 0 {
9883
opt := settings[0]
9984
if !opt.Prefork {
100-
opt.Prefork = prefork
85+
opt.Prefork = *prefork
10186
}
10287
if opt.Concurrency == 0 {
10388
opt.Concurrency = 256 * 1024
@@ -115,7 +100,7 @@ func New(settings ...*Settings) (app *App) {
115100
return
116101
}
117102
app.Settings = &Settings{
118-
Prefork: prefork,
103+
Prefork: *prefork,
119104
Concurrency: 256 * 1024,
120105
ReadBufferSize: 4096,
121106
WriteBufferSize: 4096,
@@ -318,7 +303,7 @@ func (app *App) prefork(address string) (ln net.Listener, err error) {
318303

319304
// #nosec G204
320305
for i := range childs {
321-
childs[i] = exec.Command(os.Args[0], "-prefork", "-child")
306+
childs[i] = exec.Command(os.Args[0], "-fiber-prefork", "-fiber-child")
322307
childs[i].Stdout = os.Stdout
323308
childs[i].Stderr = os.Stderr
324309
childs[i].ExtraFiles = []*os.File{fl}

0 commit comments

Comments
 (0)