From f9516577dc82c08cd3d1bdfada80db44749b97cd Mon Sep 17 00:00:00 2001 From: "jw_wonny.cha" Date: Thu, 11 Apr 2019 13:22:37 +0900 Subject: [PATCH] Add annotation / Update log in servicemgr Change-Id: I1028c4f2f3c6b856845bf82b6c6316044c4c09a6 Signed-off-by: jw_wonny.cha --- src/interface/types.go | 8 +++++++- src/servicemgr/service_execution.go | 17 +++++++++-------- src/servicemgr/servicemgr_test.go | 6 +++--- src/servicemgr/types.go | 1 + 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/interface/types.go b/src/interface/types.go index 74a4ba8..02d648e 100755 --- a/src/interface/types.go +++ b/src/interface/types.go @@ -16,4 +16,10 @@ *******************************************************************************/ package main -var logPrefix = "interface" +var ( + logPrefix = "interface" +) + +const ( + ConstWellknownPort = 56001 +) diff --git a/src/servicemgr/service_execution.go b/src/servicemgr/service_execution.go index ff4f092..1989342 100755 --- a/src/servicemgr/service_execution.go +++ b/src/servicemgr/service_execution.go @@ -36,13 +36,14 @@ type Service struct { } func (p Service) execute() (err error) { - log.Println(p.serviceName, p.paramStr) + log.Println(logPrefix, p.serviceName, p.paramStr) + log.Println(logPrefix, "parameter length :", len(p.paramStr)) cmd, pid, err := p.setService() if err != nil { return } - log.Println("Just ran subprocess ", pid) + log.Println(logPrefix, "Just ran subprocess ", pid) executeCh := make(chan error) @@ -68,7 +69,7 @@ func (p Service) setService() (cmd *exec.Cmd, pid int, err error) { err = cmd.Start() if err != nil { - log.Println(err.Error()) + log.Println(logPrefix, err.Error()) return } @@ -84,13 +85,13 @@ func (p Service) waitService(executeCh <-chan error) (status string) { if e != nil { if e.Error() == os.Kill.String() { - log.Println("Success to delete service") + log.Println(logPrefix, "Success to delete service") } else { status = ConstServiceStatusFailed - log.Println(p.serviceName, "exited with error : ", e) + log.Println(logPrefix, p.serviceName, "exited with error : ", e) } } else { - log.Println(p.serviceName, "is exited with no error") + log.Println(logPrefix, p.serviceName, "is exited with no error") } return @@ -109,10 +110,10 @@ func (p Service) notifyServiceStatus(status string) (err error) { targetURL := httpclient.ConstPrefixHTTP + p.notificationTargetURL + ConstServiceStatusNotiURI + strconv.FormatUint(p.serviceID, 10) _, statusCode, err := httpclient.DoPost(targetURL, reqbytes) if err != nil { - log.Println(err.Error()) + log.Println(logPrefix, err.Error()) } if statusCode != http.StatusOK { - log.Println(statusCode) + log.Println(logPrefix, statusCode) } } return diff --git a/src/servicemgr/servicemgr_test.go b/src/servicemgr/servicemgr_test.go index 9a3c8ba..daf49ae 100755 --- a/src/servicemgr/servicemgr_test.go +++ b/src/servicemgr/servicemgr_test.go @@ -34,10 +34,10 @@ var ( targetRemoteDeviceAddr = "127.0.0.1" targetLocalAddr, _ = common.GetOutboundIP() serviceID uint64 + notExistFileName = "NotExistFile" + keyFilePath = "./../securemgr/test/key.txt" ) -var keyFilePath string = "./../securemgr/test/key.txt" - func init() { servicemgr.Init() securemgr.Init(keyFilePath) @@ -113,7 +113,7 @@ func TestSystemtestExecuteRemoteAppFailed(t *testing.T) { time.Sleep(time.Duration(1) * time.Second) //setting - _, err := servicemgr.ExecuteApp(targetRemoteDeviceAddr, "main", nil, nil) + _, err := servicemgr.ExecuteApp(targetRemoteDeviceAddr, notExistFileName, nil, nil) time.Sleep(time.Duration(3) * time.Second) //user scenario diff --git a/src/servicemgr/types.go b/src/servicemgr/types.go index 8a0e048..92251ed 100755 --- a/src/servicemgr/types.go +++ b/src/servicemgr/types.go @@ -61,6 +61,7 @@ type StatusNotification struct { Status string `json:"Status"` } +// ConcurrentMap type type ConcurrentMap struct { sync.RWMutex items map[uint64]interface{} -- 2.7.4