subgraph / roflcoptor

Tor Control Port Filter and State Tracker Daemon
BSD 3-Clause "New" or "Revised" License
25 stars 8 forks source link

handle TERM signal, add a shutdown code path #20

Closed david415 closed 8 years ago

david415 commented 8 years ago

our shutdown code path needs to close sockets which if they are unix domain sockets causes their socket file to be removed from the filesystem. We need this behavior so that next time the daemon is stated we can recreate the unix domain socket files with the same specified names without conflict... otherwise the startup will fail if the socket files already exist.

david415 commented 8 years ago

The golang unix domain socket listener does remove the socket file when it's Close method is called. This is a pretty good blog post and proof of concept code for listen accept loop shutdown in golang:

http://zhen.org/blog/graceful-shutdown-of-go-net-dot-listeners/

david415 commented 8 years ago

please review https://github.com/subgraph/roflcoptor/pull/22/files

david415 commented 8 years ago

fixed forever https://github.com/subgraph/roflcoptor/commit/0866ee83579c3546479e2a030cb144ca4ddf3ea4