lestrrat-go / server-starter

Go port of start_server utility (Server::Starter)
MIT License
215 stars 21 forks source link

the behavior when start_server receives multiple HUP signals #9

Open harukasan opened 7 years ago

harukasan commented 7 years ago

go-server-starter implements the different to Server::Starter's one.

p5-server-starter behavior:

         old workers   action
-------  ------------  ----------------------------------------------------
1st HUP             0  spawn new worker and send TERM signal to old workers
2nd HUP             1  spawn new worker and send TERM signal to old workers
3rd HUP             2  spwan new worker and send TERM signal to old workers (stop one)
4th HUP             2  ...

go-server-starter behavior:

         old workers   action
-------  ------------  ----------------------------------------------------
1st HUP             0  spawn new worker and send TERM signal to old workers
2nd HUP             1  no action
3nd HUP             1  no action (stop one old worker)
4th HUP             0  spawn new worker and send TERM signal to old workers
                       when the all old worker exit.

I want to use the original perl's behavior with go-server-starter.

I also notice that restart = 2 is not used for now. Should we implement other options and set restart = 2?

lestrrat commented 7 years ago

I can appreciate that there's a difference, but I'm having trouble deciphering what the table you show represent.

harukasan commented 7 years ago

"old workers" represents the number of remain workers which includes oldWorkers list. My interest is the number of signals sending to old workers and I want to send the signal to old workers when send HUP to start_server again.

I just found restart = 2 in go-server-starter (I don't know the old p5 code).

lestrrat commented 7 years ago

申し訳ないですが、日本語でどうぞ!↑の説明、多分文章の時制がはっきりしてないせいで、どのタイミングで何が起こるべきだと言われてるのか全くわからないです…

harukasan commented 7 years ago

うまく伝わらなくてすいません。。

やりたいこととしては、HUPシグナルを再度送ったときに、workerがまだ死んでいなければ、再度死んでないworkerにTERMシグナルを送ることです。 p5の場合、HUPを送ると新しいプロセスの起動とTERMシグナルの送信を繰り返すので、これと同じ挙動であれば問題ありません(新しいプロセスが起動されるかどうかは問題にしていないので、起動されなくてもかまいません)。

lestrrat commented 7 years ago

なるほど、なるほど。わかりました! ちょっとこれから退席しなければいけないので次の返信は遅くなりますが、その間にコード見ておきます!

lestrrat commented 7 years ago

おまたせしました。 #11 の感じでどうでしょうかねぇ

harukasan commented 7 years ago

@lestrrat すいません!いまみました、今日夜以降確認しますので、明日コメントさせて頂きます

lestrrat commented 7 years ago

@harukasan ping?