Skip to content

Commit

Permalink
get rid of keybase.socket and kbfs.socket
Browse files Browse the repository at this point in the history
Having systemd open sockets for us is cool, but it was causing
unfortunate corner cases when the user switched back and forth between
KEYBASE_SYSTEMD=1 and KEYBASE_SYSTEMD=0 within the same session. This
mostly impacts just me, I think, cause I'm always toggling this setting,
but it hits me often enough that I don't want to risk it in the wild.
  • Loading branch information
oconnor663 committed Nov 20, 2017
1 parent d4330a3 commit 003bfe3
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 31 deletions.
5 changes: 1 addition & 4 deletions go/client/fork_server_nix.go
Expand Up @@ -31,10 +31,7 @@ func spawnServer(g *libkb.GlobalContext, cl libkb.CommandLine, forkType keybase1
// add a systemd override file (see https://askubuntu.com/q/659267/73244).
if g.Env.WantsSystemd() {
g.Log.Info("Starting keybase.service.")
// Explicitly restarting the socket ensures it gets recreated, in case
// a non-systemd invocation of the service deleted it in the meantime
// without telling systemd it was "stopped".
startCmd := exec.Command("systemctl", "--user", "restart", "keybase.socket", "keybase.service")
startCmd := exec.Command("systemctl", "--user", "restart", "keybase.service")
startCmd.Stdout = os.Stderr
startCmd.Stderr = os.Stderr
err = startCmd.Run()
Expand Down
5 changes: 5 additions & 0 deletions go/service/main.go
Expand Up @@ -784,6 +784,11 @@ func (d *Service) lockPIDFile() (err error) {
func (d *Service) ConfigRPCServer() (net.Listener, error) {
// First, check to see if we've been launched with socket activation by
// systemd. If so, the socket is already open. Otherwise open it ourselves.
// NOTE: We no longer configure our keybse.service and kbfs.service units
// to be socket-activated by default. It was causing too much trouble when
// non-systemd instances deleted the socket files. It's possible this issue
// will get fixed in future versions of systemd; see
// https://github.com/systemd/systemd/issues/7274.
listener, err := systemd.GetListenerFromEnvironment()
if err != nil {
d.G().Log.Error("unexpected error in GetListenerFromEnvironment: %#v", err)
Expand Down
5 changes: 5 additions & 0 deletions go/systemd/systemd_linux.go
Expand Up @@ -16,6 +16,11 @@ func IsRunningSystemd() bool {
return sdUtil.IsRunningSystemd()
}

// NOTE: We no longer configure our keybse.service and kbfs.service units to be
// socket-activated by default. It was causing too much trouble when
// non-systemd instances deleted the socket files. It's possible this issue
// will get fixed in future versions of systemd; see
// https://github.com/systemd/systemd/issues/7274.
func IsSocketActivated() bool {
return (os.Getenv("LISTEN_FDS") != "")
}
Expand Down
3 changes: 0 additions & 3 deletions packaging/linux/run_keybase
Expand Up @@ -64,9 +64,6 @@ start_systemd() {
# If the services weren't started with systemd, we need to kill them.
if ! was_started_with_systemd ; then
kill_all
# Our non-systemd services tend to delete systemd's socket files. Make sure
# they get recreated.
systemctl --user stop keybase.socket kbfs.socket
fi
echo Starting via systemd.
# The GUI needs access to the env var KEYBASE_START_UI. This is set to
Expand Down
3 changes: 0 additions & 3 deletions packaging/linux/systemd/kbfs.service
@@ -1,8 +1,5 @@
[Unit]
Description=Keybase Filesystem service
# kbfs.socket automatically knows to start kbfs.service, but for the reverse we
# need this explicit Requires.
Requires=kbfs.socket
Wants=keybase.service

[Service]
Expand Down
9 changes: 0 additions & 9 deletions packaging/linux/systemd/kbfs.socket

This file was deleted.

3 changes: 0 additions & 3 deletions packaging/linux/systemd/keybase.service
@@ -1,8 +1,5 @@
[Unit]
Description=Keybase core service
# keybase.socket automatically knows to start keybase.service, but for the
# reverse we need this explicit Requires.
Requires=keybase.socket

[Service]
# "notify" means we promise to call SdNotify() at the end of startup.
Expand Down
9 changes: 0 additions & 9 deletions packaging/linux/systemd/keybase.socket

This file was deleted.

0 comments on commit 003bfe3

Please sign in to comment.