Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should be able to pass additional FDs #53

Open
akamensky opened this issue Feb 3, 2019 · 5 comments
Open

Should be able to pass additional FDs #53

akamensky opened this issue Feb 3, 2019 · 5 comments

Comments

@akamensky
Copy link

Right now there is not way to get additional FDs to be passed from parent to daemon.

My goal is to open TCP socket, then get FD (using TCPListener.File()), then pass that FD to the daemon and convert it back to Listener (using net.FileListener())

I think this should be totally doable and not hard to implement, so I don't see why it was not there from the start. There are more uses to this functionality than just this.

@sherlockblaze
Copy link

@akamensky Hey man, did you get a implement now? I want the feature you mentioned too

@akamensky
Copy link
Author

@sherlockblaze Nope, to get that working I would need to rewrite large part of this package.

@sherlockblaze
Copy link

@akamensky I think I got it already.
When you use the lib to start a daemon thread, you should set Args for it.

cntxt := &daemon.Context{
		PidFileName: "pid",
		PidFilePerm: 0644,
		LogFileName: "log",
		LogFilePerm: 0640,
		WorkDir:     "./",
		Umask:       027,
		Args:        []string{"[go-daemon sample]", "test"},
	}

And the Args just like the command line you use. Like nginx start, arg[0] is ngxin and arg[1] is start and like. So, you just need to set the args with your command by using a golang slice, you can achieve your goal.

@akamensky
Copy link
Author

@sherlockblaze command line arguments have nothing to do with file descriptors...

@sherlockblaze
Copy link

@akamensky sorry man, I misunderstood your purpose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants