Skip to content

Conversation

@Lagovas
Copy link
Collaborator

@Lagovas Lagovas commented Aug 3, 2022

Found that process reloading on SIGHUP stopped properly handling for acra-server and acra-translator. Previously it used first argument of the process which is process's name. Under the hood golang calls execve which doesn't search binary in PATH. Linux has execlp(), execvp(), and execvpe() functions for that. But instead of using raw syscall's we use golang's wrappers from syscall package which doesn't provide these functions. Otherwise it has portability and do other useful things like child checking, lock handling, etc

So, in this PR added searching absolute path of binary from binary name before calling ForkExec. Additionally added integration tests that checks sockets forwarding to child process and pulling config_file changes on SIGHUP.

Checklist

}
log.Debugf("Forking new process of %s", ServiceName)

binaryPath, err := exec.LookPath(os.Args[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure (and should we) that the binaryPath is the same executable as the current Acra instance? I can image situations, when someone puts another acra executable earlier in PATH, so after the sighup another binary will be called. But, is it worth to worry about?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we don't sure. Golang doesn't fork syscall due to complicated runtime and fork limitations - https://stackoverflow.com/questions/28370646/how-do-i-fork-a-go-process
execve* requires path to executable that should be loaded. We try to find executable using same ENV variables used to run process itself. But yes, if we have PATH=/dir1:/dir2 and acra-server was loaded from /dir2/acra-server and before sighup somebody place acra-server in /dir1 then we will load new binary.

@Lagovas Lagovas requested a review from G1gg1L3s August 5, 2022 09:39
Copy link
Contributor

@Zhaars Zhaars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is clear to me

Copy link
Contributor

@G1gg1L3s G1gg1L3s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Copy link
Contributor

@G1gg1L3s G1gg1L3s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Lagovas Lagovas merged commit c5014d5 into master Aug 9, 2022
@Lagovas Lagovas deleted the lagovas/T2625-test-sighup-handler branch August 9, 2022 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants