)
var (
- server *httptest.Server
testURL string
)
func init() {
devicemgr.InitDeviceMgr()
- servicemgr.InitServiceMap()
+ servicemgr.Init()
discoverymgr.InitDiscovery()
router := NewRouter()
- server = httptest.NewServer(router)
+ server := httptest.NewServer(router)
testURL = server.URL
ConstServiceStatusNotiURI = "/api/v1/servicemgr/services/notification/"
//ConstLocalTarget is for knowing local environments
- ConstLocalTarget = "local"
+ ConstLocalTarget = "localhost"
//ConstPrefixHTTP is "http://"
ConstPrefixHTTP = "http://"
"sync/atomic"
)
-// InitServiceMap is for initializing service map
-func InitServiceMap() {
+// initServiceMap is for initializing service map
+func initServiceMap() {
ServiceMap = ConcurrentMap{items: make(map[uint64]interface{})}
}
"strings"
)
+// Init is for initializing serviemgr
+func Init() {
+ initServiceMap()
+}
+
// ExecuteApp function
func ExecuteApp(target string, name string, args []string, notiChan chan string) (serviceID uint64, err error) {
appInfo := make(map[string]interface{})
}
appInfo[ConstKeyServiceName] = name
- if strings.Compare(target, getOutboundIP()) == 0 {
+ if strings.Compare(target, getOutboundIP()) == 0 || strings.Compare(target, ConstLocalTarget) == 0 {
appInfo[ConstKeyNotiTargetURL] = ConstLocalTarget
err = executeLocalEnv(appInfo)
} else {
// Run is trigger point executing binary
func Run(distService map[string]interface{}) {
var serviceID uint64
-
switch distService[ConstKeyServiceID].(type) {
case uint64:
serviceID = distService[ConstKeyServiceID].(uint64)
} else {
args = nil
}
+
notificationTargetURL := distService[ConstKeyNotiTargetURL].(string)
service := Service{serviceID, serviceName, args, notificationTargetURL}
-
service.execute()
}