Skip to content

Commit

Permalink
write .cache/keybase/service.version on service startup
Browse files Browse the repository at this point in the history
This provides an easy way for updated clients to find out what version
of the service is currently running, so that they can bounce it if need
be.

Closes keybase#415.
  • Loading branch information
oconnor663 committed May 13, 2015
1 parent 9bb3d50 commit 941a75e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions go/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package service

import (
"fmt"
"io/ioutil"
"net"
"os"
"path"

"github.com/codegangsta/cli"
"github.com/keybase/client/go/libcmdline"
Expand Down Expand Up @@ -56,6 +58,11 @@ func (d *Service) RunClient() (err error) {
func (d *Service) Run() (err error) {
G.Service = true

err = d.writeVersionFile()
if err != nil {
return
}

if len(d.chdirTo) != 0 {
e_tmp := os.Chdir(d.chdirTo)
if e_tmp != nil {
Expand All @@ -81,6 +88,13 @@ func (d *Service) Run() (err error) {
return
}

// If the daemon is already running, we need to be able to check what version
// it is, in case the client has been updated.
func (d *Service) writeVersionFile() error {
versionFilePath := path.Join(G.Env.GetCacheDir(), "service.version")
return ioutil.WriteFile(versionFilePath, []byte(libkb.CLIENT_VERSION), 0644)
}

func (d *Service) ReleaseLock() error {
return d.lockPid.Close()
}
Expand Down

0 comments on commit 941a75e

Please sign in to comment.