From 222fd744e67d2b57dad31ab8789e4a3e00003e78 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Thu, 21 Nov 2019 19:14:41 +0300 Subject: [PATCH] Rename app config's `SockFile` => `SockFilePath` to make it more clear. Path now is being passed correcrtly from visor --- pkg/app/appcommon/config.go | 12 +++++------ pkg/app/appserver/proc.go | 6 +++--- pkg/visor/rpc_test.go | 10 +++++----- pkg/visor/visor.go | 12 +++++------ pkg/visor/visor_test.go | 40 ++++++++++++++++++------------------- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/pkg/app/appcommon/config.go b/pkg/app/appcommon/config.go index 027d435363..7fd1ca05b6 100644 --- a/pkg/app/appcommon/config.go +++ b/pkg/app/appcommon/config.go @@ -2,10 +2,10 @@ package appcommon // Config defines configuration parameters for `Proc`. type Config struct { - Name string `json:"name"` - Version string `json:"version"` - SockFile string `json:"sock_file"` - VisorPK string `json:"visor_pk"` - BinaryDir string `json:"binary_dir"` - WorkDir string `json:"work_dir"` + Name string `json:"name"` + Version string `json:"version"` + SockFilePath string `json:"sock_file_path"` + VisorPK string `json:"visor_pk"` + BinaryDir string `json:"binary_dir"` + WorkDir string `json:"work_dir"` } diff --git a/pkg/app/appserver/proc.go b/pkg/app/appserver/proc.go index f06f27d941..410924abeb 100644 --- a/pkg/app/appserver/proc.go +++ b/pkg/app/appserver/proc.go @@ -36,7 +36,7 @@ func NewProc(log *logging.Logger, c appcommon.Config, args []string, stdout, std env := make([]string, 0, 3) env = append(env, fmt.Sprintf(appKeyEnvFormat, key)) - env = append(env, fmt.Sprintf(sockFileEnvFormat, c.SockFile)) + env = append(env, fmt.Sprintf(sockFileEnvFormat, c.SockFilePath)) env = append(env, fmt.Sprintf(visorPKEnvFormat, c.VisorPK)) cmd := exec.Command(binaryPath, args...) // nolint:gosec @@ -48,7 +48,7 @@ func NewProc(log *logging.Logger, c appcommon.Config, args []string, stdout, std cmd.Stderr = stderr rpcS, err := New(logging.MustGetLogger(fmt.Sprintf("app_rpc_server_%s", key)), - c.SockFile, key) + c.SockFilePath, key) if err != nil { return nil, err } @@ -79,7 +79,7 @@ func (p *Proc) Run() error { return nil } -// Stop stops the applicacation. It stops the process and +// Stop stops the application. It stops the process and // shuts down the RPC server. func (p *Proc) Stop() error { p.closeRPCServer() diff --git a/pkg/visor/rpc_test.go b/pkg/visor/rpc_test.go index 345d2b9786..f30b6c64e0 100644 --- a/pkg/visor/rpc_test.go +++ b/pkg/visor/rpc_test.go @@ -147,11 +147,11 @@ func TestStartStopApp(t *testing.T) { pm := &appserver.MockProcManager{} appCfg1 := appcommon.Config{ - Name: app, - Version: apps[0].Version, - SockFile: nodeCfg.AppServerSockFile, - VisorPK: nodeCfg.Node.StaticPubKey.Hex(), - WorkDir: filepath.Join("", app, fmt.Sprintf("v%s", apps[0].Version)), + Name: app, + Version: apps[0].Version, + SockFilePath: nodeCfg.AppServerSockFile, + VisorPK: nodeCfg.Node.StaticPubKey.Hex(), + WorkDir: filepath.Join("", app, fmt.Sprintf("v%s", apps[0].Version)), } appArgs1 := append([]string{filepath.Join(node.dir(), app)}, apps[0].Args...) appPID1 := appcommon.ProcID(10) diff --git a/pkg/visor/visor.go b/pkg/visor/visor.go index 5ed60c1ccf..8c657405ab 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -406,12 +406,12 @@ func (node *Node) SpawnApp(config *AppConfig, startCh chan<- struct{}) (err erro } appCfg := appcommon.Config{ - Name: config.App, - Version: config.Version, - SockFile: node.conf.AppServerSockFile, - VisorPK: node.conf.Node.StaticPubKey.Hex(), - BinaryDir: node.appsPath, - WorkDir: filepath.Join(node.localPath, config.App, fmt.Sprintf("v%s", config.Version)), + Name: config.App, + Version: config.Version, + SockFilePath: filepath.Join(node.dir(), node.conf.AppServerSockFile), + VisorPK: node.conf.Node.StaticPubKey.Hex(), + BinaryDir: node.appsPath, + WorkDir: filepath.Join(node.localPath, config.App, fmt.Sprintf("v%s", config.Version)), } if _, err := ensureDir(appCfg.WorkDir); err != nil { diff --git a/pkg/visor/visor_test.go b/pkg/visor/visor_test.go index 08be99edcd..9dc786aec7 100644 --- a/pkg/visor/visor_test.go +++ b/pkg/visor/visor_test.go @@ -117,11 +117,11 @@ func TestNodeStartClose(t *testing.T) { pm := &appserver.MockProcManager{} appCfg1 := appcommon.Config{ - Name: apps[0].App, - Version: apps[0].Version, - SockFile: nodeCfg.AppServerSockFile, - VisorPK: nodeCfg.Node.StaticPubKey.Hex(), - WorkDir: filepath.Join("", apps[0].App, fmt.Sprintf("v%s", apps[0].Version)), + Name: apps[0].App, + Version: apps[0].Version, + SockFilePath: nodeCfg.AppServerSockFile, + VisorPK: nodeCfg.Node.StaticPubKey.Hex(), + WorkDir: filepath.Join("", apps[0].App, fmt.Sprintf("v%s", apps[0].Version)), } appArgs1 := append([]string{filepath.Join(node.dir(), apps[0].App)}, apps[0].Args...) appPID1 := appcommon.ProcID(10) @@ -196,11 +196,11 @@ func TestNodeSpawnApp(t *testing.T) { pm := &appserver.MockProcManager{} appCfg := appcommon.Config{ - Name: app.App, - Version: app.Version, - SockFile: nodeCfg.AppServerSockFile, - VisorPK: nodeCfg.Node.StaticPubKey.Hex(), - WorkDir: filepath.Join("", app.App, fmt.Sprintf("v%s", app.Version)), + Name: app.App, + Version: app.Version, + SockFilePath: nodeCfg.AppServerSockFile, + VisorPK: nodeCfg.Node.StaticPubKey.Hex(), + WorkDir: filepath.Join("", app.App, fmt.Sprintf("v%s", app.Version)), } appArgs := append([]string{filepath.Join(node.dir(), app.App)}, app.Args...) pm.On("Wait", app.App).Return(testhelpers.NoErr) @@ -254,11 +254,11 @@ func TestNodeSpawnAppValidations(t *testing.T) { pm := &appserver.MockProcManager{} appCfg := appcommon.Config{ - Name: app.App, - Version: app.Version, - SockFile: c.AppServerSockFile, - VisorPK: c.Node.StaticPubKey.Hex(), - WorkDir: filepath.Join("", app.App, fmt.Sprintf("v%s", app.Version)), + Name: app.App, + Version: app.Version, + SockFilePath: c.AppServerSockFile, + VisorPK: c.Node.StaticPubKey.Hex(), + WorkDir: filepath.Join("", app.App, fmt.Sprintf("v%s", app.Version)), } appArgs := append([]string{filepath.Join(node.dir(), app.App)}, app.Args...) @@ -290,11 +290,11 @@ func TestNodeSpawnAppValidations(t *testing.T) { pm := &appserver.MockProcManager{} appCfg := appcommon.Config{ - Name: app.App, - Version: app.Version, - SockFile: c.AppServerSockFile, - VisorPK: c.Node.StaticPubKey.Hex(), - WorkDir: filepath.Join("", app.App, fmt.Sprintf("v%s", app.Version)), + Name: app.App, + Version: app.Version, + SockFilePath: c.AppServerSockFile, + VisorPK: c.Node.StaticPubKey.Hex(), + WorkDir: filepath.Join("", app.App, fmt.Sprintf("v%s", app.Version)), } appArgs := append([]string{filepath.Join(node.dir(), app.App)}, app.Args...)