mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-11-15 16:36:38 +01:00
CLI: Load stored scripts only from intended path;Fix SIGNAL interrupt of HIDScripts started with 'cli hid run'
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package cli_client
|
package cli_client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/mame82/P4wnP1_go/common"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -16,7 +18,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
tmpHidCommands = ""
|
tmpHidCommands = ""
|
||||||
tmpRunFromServerPath = ""
|
tmpRunStored = ""
|
||||||
tmpHidTimeout = uint32(0) // values < 0 = endless
|
tmpHidTimeout = uint32(0) // values < 0 = endless
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -91,7 +93,7 @@ var hidJobCancelCmd = &cobra.Command{
|
|||||||
// The logic above applies to both, running scripts synchronous with `run` or asynchronous with `job`
|
// The logic above applies to both, running scripts synchronous with `run` or asynchronous with `job`
|
||||||
|
|
||||||
|
|
||||||
func parseHIDRunScripCmd(cmd *cobra.Command, args []string) (serverScriptPath string, err error) {
|
func parseHIDRunScriptCmd(cmd *cobra.Command, args []string) (serverScriptPath string, err error) {
|
||||||
/*
|
/*
|
||||||
readFromStdin := false
|
readFromStdin := false
|
||||||
localFile := false //if true readFilePath refers to a file on the host of the rpcClient, else to a file on the rpcServer
|
localFile := false //if true readFilePath refers to a file on the host of the rpcClient, else to a file on the rpcServer
|
||||||
@@ -104,7 +106,7 @@ func parseHIDRunScripCmd(cmd *cobra.Command, args []string) (serverScriptPath st
|
|||||||
|
|
||||||
|
|
||||||
cFlagSet := cmd.Flags().ShorthandLookup("c").Changed
|
cFlagSet := cmd.Flags().ShorthandLookup("c").Changed
|
||||||
rFlagSet := cmd.Flags().ShorthandLookup("r").Changed
|
rFlagSet := cmd.Flags().ShorthandLookup("n").Changed
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case !rFlagSet && !cFlagSet:
|
case !rFlagSet && !cFlagSet:
|
||||||
@@ -125,13 +127,13 @@ func parseHIDRunScripCmd(cmd *cobra.Command, args []string) (serverScriptPath st
|
|||||||
} else {
|
} else {
|
||||||
// assume RPC client is run from same host as RPC server and the script path refers to a local file
|
// assume RPC client is run from same host as RPC server and the script path refers to a local file
|
||||||
transferNeeded = false
|
transferNeeded = false
|
||||||
serverScriptPath = args[0]
|
serverScriptPath = common.PATH_HID_SCRIPTS + "/" + args[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case rFlagSet:
|
case rFlagSet:
|
||||||
// the flag represents a script path on the RPC server, no matter where the RPC client is running, so we assume the script is already there
|
// the flag represents a script path on the RPC server, no matter where the RPC client is running, so we assume the script is already there
|
||||||
transferNeeded = false
|
transferNeeded = false
|
||||||
serverScriptPath = tmpRunFromServerPath
|
serverScriptPath = common.PATH_HID_SCRIPTS + "/" + tmpRunStored
|
||||||
case cFlagSet:
|
case cFlagSet:
|
||||||
// script content is provided by parameter and needs to be transferred
|
// script content is provided by parameter and needs to be transferred
|
||||||
transferNeeded = true
|
transferNeeded = true
|
||||||
@@ -178,15 +180,17 @@ func parseHIDRunScripCmd(cmd *cobra.Command, args []string) (serverScriptPath st
|
|||||||
if err != nil { return "",errors.New(fmt.Sprintf("Error transfering HIDScript content to P4wnP1 Server: %v", err))}
|
if err != nil { return "",errors.New(fmt.Sprintf("Error transfering HIDScript content to P4wnP1 Server: %v", err))}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func cobraHidRun(cmd *cobra.Command, args []string) {
|
func cobraHidRun(cmd *cobra.Command, args []string) {
|
||||||
serverScriptFilePath, err := parseHIDRunScripCmd(cmd,args)
|
serverScriptFilePath, err := parseHIDRunScriptCmd(cmd,args)
|
||||||
if err != nil { log.Fatal(err)}
|
if err != nil { log.Fatal(err)}
|
||||||
|
|
||||||
res,err := ClientHIDRunScript(StrRemoteHost, StrRemotePort, serverScriptFilePath, tmpHidTimeout)
|
ctx,cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
res,err := ClientHIDRunScript(StrRemoteHost, StrRemotePort, ctx, serverScriptFilePath, tmpHidTimeout)
|
||||||
if err != nil { log.Fatal(err) }
|
if err != nil { log.Fatal(err) }
|
||||||
|
|
||||||
fmt.Printf("Result:\n%s\n", res.ResultJson)
|
fmt.Printf("Result:\n%s\n", res.ResultJson)
|
||||||
@@ -195,7 +199,7 @@ func cobraHidRun(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
|
|
||||||
func cobraHidJob(cmd *cobra.Command, args []string) {
|
func cobraHidJob(cmd *cobra.Command, args []string) {
|
||||||
serverScriptFilePath, err := parseHIDRunScripCmd(cmd,args)
|
serverScriptFilePath, err := parseHIDRunScriptCmd(cmd,args)
|
||||||
if err != nil { log.Fatal(err)}
|
if err != nil { log.Fatal(err)}
|
||||||
|
|
||||||
|
|
||||||
@@ -226,10 +230,10 @@ func init() {
|
|||||||
hidJobCmd.AddCommand(hidJobCancelCmd)
|
hidJobCmd.AddCommand(hidJobCancelCmd)
|
||||||
|
|
||||||
hidRunCmd.Flags().StringVarP(&tmpHidCommands, "commands","c", "", "HIDScript commands to run, given as string")
|
hidRunCmd.Flags().StringVarP(&tmpHidCommands, "commands","c", "", "HIDScript commands to run, given as string")
|
||||||
hidRunCmd.Flags().StringVarP(&tmpRunFromServerPath, "server-path","r", "", "Load HIDScript from given path on P4wnP1 server")
|
hidRunCmd.Flags().StringVarP(&tmpRunStored, "name","n", "", "Run a stored HIDScript")
|
||||||
hidRunCmd.Flags().Uint32VarP(&tmpHidTimeout, "timeout","t", 0, "Interrupt HIDScript after this timeout (seconds)")
|
hidRunCmd.Flags().Uint32VarP(&tmpHidTimeout, "timeout","t", 0, "Interrupt HIDScript after this timeout (seconds)")
|
||||||
|
|
||||||
hidJobCmd.Flags().StringVarP(&tmpHidCommands, "commands","c", "", "HIDScript commands to run, given as string")
|
hidJobCmd.Flags().StringVarP(&tmpHidCommands, "commands","c", "", "HIDScript commands to run, given as string")
|
||||||
hidJobCmd.Flags().StringVarP(&tmpRunFromServerPath, "server-path","r", "", "Load HIDScript from given path on P4wnP1 server")
|
hidJobCmd.Flags().StringVarP(&tmpRunStored, "name","n", "", "Run a stored HIDScript")
|
||||||
hidJobCmd.Flags().Uint32VarP(&tmpHidTimeout, "timeout","t", 0, "Interrupt HIDScript after this timeout (seconds)")
|
hidJobCmd.Flags().Uint32VarP(&tmpHidTimeout, "timeout","t", 0, "Interrupt HIDScript after this timeout (seconds)")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
pb "github.com/mame82/P4wnP1_go/proto"
|
pb "github.com/mame82/P4wnP1_go/proto"
|
||||||
"errors"
|
"errors"
|
||||||
"golang.org/x/net/context"
|
"context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@@ -320,7 +320,7 @@ func ClientDeployWifiSettings(host string, port string, settings *pb.WiFiSetting
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClientHIDRunScript(host string, port string, scriptPath string, timeoutSeconds uint32) (scriptRes *pb.HIDScriptResult, err error) {
|
func ClientHIDRunScript(host string, port string, ctx context.Context, scriptPath string, timeoutSeconds uint32) (scriptRes *pb.HIDScriptResult, err error) {
|
||||||
scriptReq := &pb.HIDScriptRequest{
|
scriptReq := &pb.HIDScriptRequest{
|
||||||
ScriptPath: scriptPath,
|
ScriptPath: scriptPath,
|
||||||
TimeoutSeconds: timeoutSeconds,
|
TimeoutSeconds: timeoutSeconds,
|
||||||
@@ -332,10 +332,8 @@ func ClientHIDRunScript(host string, port string, scriptPath string, timeoutSeco
|
|||||||
defer connection.Close()
|
defer connection.Close()
|
||||||
|
|
||||||
rpcClient := pb.NewP4WNP1Client(connection)
|
rpcClient := pb.NewP4WNP1Client(connection)
|
||||||
// ctx, cancel := context.WithTimeout(context.Background(), time.Second * 30)
|
|
||||||
// defer cancel()
|
|
||||||
|
|
||||||
scriptRes,err = rpcClient.HIDRunScript(context.Background(), scriptReq)
|
scriptRes,err = rpcClient.HIDRunScript(ctx, scriptReq)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package service
|
package common
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PATH_ROOT = "/usr/local/P4wnP1"
|
PATH_ROOT = "/usr/local/P4wnP1"
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ func (tam *TriggerActionManager) executeActionStartHidScript(evt *pb.Event, ta *
|
|||||||
|
|
||||||
fmt.Printf("Trigger '%s' fired -> executing action '%s' ('%s')\n", triggerName, actionName, action.ScriptName)
|
fmt.Printf("Trigger '%s' fired -> executing action '%s' ('%s')\n", triggerName, actionName, action.ScriptName)
|
||||||
|
|
||||||
scriptPath := PATH_HID_SCRIPTS + "/" + action.ScriptName
|
scriptPath := common.PATH_HID_SCRIPTS + "/" + action.ScriptName
|
||||||
preScript := fmt.Sprintf("var TRIGGER='%s';\n", triggerName)
|
preScript := fmt.Sprintf("var TRIGGER='%s';\n", triggerName)
|
||||||
|
|
||||||
switch tt {
|
switch tt {
|
||||||
@@ -490,7 +490,7 @@ func (tam *TriggerActionManager) executeActionBashScript(evt *pb.Event, ta *pb.T
|
|||||||
triggerName := triggerTypeString[tt]
|
triggerName := triggerTypeString[tt]
|
||||||
actionName := actionTypeString[at]
|
actionName := actionTypeString[at]
|
||||||
|
|
||||||
scriptPath := PATH_BASH_SCRIPTS + "/" + action.ScriptName
|
scriptPath := common.PATH_BASH_SCRIPTS + "/" + action.ScriptName
|
||||||
env := []string{
|
env := []string{
|
||||||
fmt.Sprintf("TRIGGER=%s", triggerName),
|
fmt.Sprintf("TRIGGER=%s", triggerName),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/mame82/P4wnP1_go/common"
|
||||||
"github.com/mame82/P4wnP1_go/hid"
|
"github.com/mame82/P4wnP1_go/hid"
|
||||||
pb "github.com/mame82/P4wnP1_go/proto"
|
pb "github.com/mame82/P4wnP1_go/proto"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -740,9 +741,9 @@ func (gm *UsbGadgetManager) DeployGadgetSettings(settings *pb.GadgetSettings) (e
|
|||||||
//Provide the backing image
|
//Provide the backing image
|
||||||
file := settings.UmsSettings.File
|
file := settings.UmsSettings.File
|
||||||
if settings.UmsSettings.Cdrom {
|
if settings.UmsSettings.Cdrom {
|
||||||
file = PATH_IMAGE_CDROM + "/" + file
|
file = common.PATH_IMAGE_CDROM + "/" + file
|
||||||
} else {
|
} else {
|
||||||
file = PATH_IMAGE_FLASHDRIVE + "/" + file
|
file = common.PATH_IMAGE_FLASHDRIVE + "/" + file
|
||||||
}
|
}
|
||||||
ioutil.WriteFile(funcdir+"/lun.0/file", []byte(file), os.ModePerm) // Set backing file (or block device) for USB Mass Storage
|
ioutil.WriteFile(funcdir+"/lun.0/file", []byte(file), os.ModePerm) // Set backing file (or block device) for USB Mass Storage
|
||||||
|
|
||||||
@@ -782,12 +783,12 @@ func (gm *UsbGadgetManager) DeployGadgetSettings(settings *pb.GadgetSettings) (e
|
|||||||
|
|
||||||
//log.Printf("Starting HID controller (kbd %s, mouse %s)...\n", devPathKeyboard, devPathMouse)
|
//log.Printf("Starting HID controller (kbd %s, mouse %s)...\n", devPathKeyboard, devPathMouse)
|
||||||
var errH error
|
var errH error
|
||||||
gm.hidCtl, errH = hid.NewHIDController(context.Background(), devPathKeyboard, PATH_KEYBOARD_LANGUAGE_MAPS, devPathMouse)
|
gm.hidCtl, errH = hid.NewHIDController(context.Background(), devPathKeyboard, common.PATH_KEYBOARD_LANGUAGE_MAPS, devPathMouse)
|
||||||
gm.hidCtl.SetEventHandler(gm)
|
gm.hidCtl.SetEventHandler(gm)
|
||||||
if errH != nil {
|
if errH != nil {
|
||||||
log.Printf("ERROR: Couldn't bring up an instance of HIDController for keyboard: '%s', mouse: '%s' and mapping path '%s'\nReason: %v\n", devPathKeyboard, devPathMouse, PATH_KEYBOARD_LANGUAGE_MAPS, errH)
|
log.Printf("ERROR: Couldn't bring up an instance of HIDController for keyboard: '%s', mouse: '%s' and mapping path '%s'\nReason: %v\n", devPathKeyboard, devPathMouse, common.PATH_KEYBOARD_LANGUAGE_MAPS, errH)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("HIDController for keyboard: '%s', mouse: '%s' and mapping path '%s' initialized\n", devPathKeyboard, devPathMouse, PATH_KEYBOARD_LANGUAGE_MAPS)
|
log.Printf("HIDController for keyboard: '%s', mouse: '%s' and mapping path '%s' initialized\n", devPathKeyboard, devPathMouse, common.PATH_KEYBOARD_LANGUAGE_MAPS)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if gm.hidCtl != nil { gm.hidCtl.Abort() }
|
if gm.hidCtl != nil { gm.hidCtl.Abort() }
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ type server struct {
|
|||||||
|
|
||||||
func (s *server) ListUmsImageFlashdrive(ctx context.Context, e *pb.Empty) (sa *pb.StringMessageArray, err error) {
|
func (s *server) ListUmsImageFlashdrive(ctx context.Context, e *pb.Empty) (sa *pb.StringMessageArray, err error) {
|
||||||
sa = &pb.StringMessageArray{}
|
sa = &pb.StringMessageArray{}
|
||||||
scripts,err := ListFilesOfFolder(PATH_IMAGE_FLASHDRIVE, ".img", ".bin")
|
scripts,err := ListFilesOfFolder(common.PATH_IMAGE_FLASHDRIVE, ".img", ".bin")
|
||||||
if err != nil { return sa,err }
|
if err != nil { return sa,err }
|
||||||
sa.MsgArray = scripts
|
sa.MsgArray = scripts
|
||||||
return
|
return
|
||||||
@@ -63,7 +63,7 @@ func (s *server) ListUmsImageFlashdrive(ctx context.Context, e *pb.Empty) (sa *p
|
|||||||
|
|
||||||
func (s *server) ListUmsImageCdrom(ctx context.Context, e *pb.Empty) (sa *pb.StringMessageArray, err error) {
|
func (s *server) ListUmsImageCdrom(ctx context.Context, e *pb.Empty) (sa *pb.StringMessageArray, err error) {
|
||||||
sa = &pb.StringMessageArray{}
|
sa = &pb.StringMessageArray{}
|
||||||
scripts,err := ListFilesOfFolder(PATH_IMAGE_CDROM, ".iso")
|
scripts,err := ListFilesOfFolder(common.PATH_IMAGE_CDROM, ".iso")
|
||||||
if err != nil { return sa,err }
|
if err != nil { return sa,err }
|
||||||
sa.MsgArray = scripts
|
sa.MsgArray = scripts
|
||||||
return
|
return
|
||||||
@@ -386,7 +386,7 @@ func (s *server) DBBackup(ctx context.Context, filename *pb.StringMessage) (e *p
|
|||||||
fname = fname + ".db"
|
fname = fname + ".db"
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.rootSvc.SubSysDataStore.Backup(PATH_DATA_STORE_BACKUP + "/" + fname)
|
err = s.rootSvc.SubSysDataStore.Backup(common.PATH_DATA_STORE_BACKUP + "/" + fname)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,13 +398,13 @@ func (s *server) DBRestore(ctx context.Context, filename *pb.StringMessage) (e *
|
|||||||
if lext := strings.ToLower(ext); lext != ".db" {
|
if lext := strings.ToLower(ext); lext != ".db" {
|
||||||
fname = fname + ".db"
|
fname = fname + ".db"
|
||||||
}
|
}
|
||||||
err = s.rootSvc.SubSysDataStore.Restore(PATH_DATA_STORE_BACKUP + "/" + fname, true)
|
err = s.rootSvc.SubSysDataStore.Restore(common.PATH_DATA_STORE_BACKUP + "/" + fname, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) ListStoredDBBackups(ctx context.Context, e *pb.Empty) (ma *pb.StringMessageArray, err error) {
|
func (s *server) ListStoredDBBackups(ctx context.Context, e *pb.Empty) (ma *pb.StringMessageArray, err error) {
|
||||||
ma = &pb.StringMessageArray{}
|
ma = &pb.StringMessageArray{}
|
||||||
scripts,err := ListFilesOfFolder(PATH_DATA_STORE_BACKUP, ".db")
|
scripts,err := ListFilesOfFolder(common.PATH_DATA_STORE_BACKUP, ".db")
|
||||||
if err != nil { return ma,err }
|
if err != nil { return ma,err }
|
||||||
ma.MsgArray = scripts
|
ma.MsgArray = scripts
|
||||||
return
|
return
|
||||||
@@ -480,7 +480,7 @@ func (s *server) ListStoredUSBSettings(ctx context.Context, e *pb.Empty) (sa *pb
|
|||||||
|
|
||||||
func (s *server) ListStoredHIDScripts(context.Context, *pb.Empty) (sa *pb.StringMessageArray, err error) {
|
func (s *server) ListStoredHIDScripts(context.Context, *pb.Empty) (sa *pb.StringMessageArray, err error) {
|
||||||
sa = &pb.StringMessageArray{}
|
sa = &pb.StringMessageArray{}
|
||||||
scripts,err := ListFilesOfFolder(PATH_HID_SCRIPTS, ".js", ".javascript")
|
scripts,err := ListFilesOfFolder(common.PATH_HID_SCRIPTS, ".js", ".javascript")
|
||||||
if err != nil { return sa,err }
|
if err != nil { return sa,err }
|
||||||
sa.MsgArray = scripts
|
sa.MsgArray = scripts
|
||||||
return
|
return
|
||||||
@@ -488,7 +488,7 @@ func (s *server) ListStoredHIDScripts(context.Context, *pb.Empty) (sa *pb.String
|
|||||||
|
|
||||||
func (s *server) ListStoredBashScripts(context.Context, *pb.Empty) (sa *pb.StringMessageArray, err error) {
|
func (s *server) ListStoredBashScripts(context.Context, *pb.Empty) (sa *pb.StringMessageArray, err error) {
|
||||||
sa = &pb.StringMessageArray{}
|
sa = &pb.StringMessageArray{}
|
||||||
scripts,err := ListFilesOfFolder(PATH_BASH_SCRIPTS, ".sh", ".bash")
|
scripts,err := ListFilesOfFolder(common.PATH_BASH_SCRIPTS, ".sh", ".bash")
|
||||||
if err != nil { return sa,err }
|
if err != nil { return sa,err }
|
||||||
sa.MsgArray = scripts
|
sa.MsgArray = scripts
|
||||||
return
|
return
|
||||||
@@ -672,9 +672,9 @@ func (s *server) FSWriteFile(ctx context.Context, req *pb.WriteFileRequest) (emp
|
|||||||
case pb.AccessibleFolder_TMP:
|
case pb.AccessibleFolder_TMP:
|
||||||
filePath = "/tmp" + filePath
|
filePath = "/tmp" + filePath
|
||||||
case pb.AccessibleFolder_BASH_SCRIPTS:
|
case pb.AccessibleFolder_BASH_SCRIPTS:
|
||||||
filePath = PATH_BASH_SCRIPTS + filePath
|
filePath = common.PATH_BASH_SCRIPTS + filePath
|
||||||
case pb.AccessibleFolder_HID_SCRIPTS:
|
case pb.AccessibleFolder_HID_SCRIPTS:
|
||||||
filePath = PATH_HID_SCRIPTS + filePath
|
filePath = common.PATH_HID_SCRIPTS + filePath
|
||||||
default:
|
default:
|
||||||
err = errors.New("Unknown folder")
|
err = errors.New("Unknown folder")
|
||||||
return
|
return
|
||||||
@@ -692,9 +692,9 @@ func (s *server) FSReadFile(ctx context.Context, req *pb.ReadFileRequest) (resp
|
|||||||
case pb.AccessibleFolder_TMP:
|
case pb.AccessibleFolder_TMP:
|
||||||
filePath = "/tmp" + filePath
|
filePath = "/tmp" + filePath
|
||||||
case pb.AccessibleFolder_BASH_SCRIPTS:
|
case pb.AccessibleFolder_BASH_SCRIPTS:
|
||||||
filePath = PATH_BASH_SCRIPTS + filePath
|
filePath = common.PATH_BASH_SCRIPTS + filePath
|
||||||
case pb.AccessibleFolder_HID_SCRIPTS:
|
case pb.AccessibleFolder_HID_SCRIPTS:
|
||||||
filePath = PATH_HID_SCRIPTS + filePath
|
filePath = common.PATH_HID_SCRIPTS + filePath
|
||||||
default:
|
default:
|
||||||
err = errors.New("Unknown folder")
|
err = errors.New("Unknown folder")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/mame82/P4wnP1_go/common"
|
||||||
"github.com/mame82/P4wnP1_go/common_web"
|
"github.com/mame82/P4wnP1_go/common_web"
|
||||||
pb "github.com/mame82/P4wnP1_go/proto"
|
pb "github.com/mame82/P4wnP1_go/proto"
|
||||||
"github.com/mame82/P4wnP1_go/service/datastore"
|
"github.com/mame82/P4wnP1_go/service/datastore"
|
||||||
@@ -140,7 +141,7 @@ func NewService() (svc *Service, err error) {
|
|||||||
svc = &Service{}
|
svc = &Service{}
|
||||||
svc.Ctx,svc.Cancel = context.WithCancel(context.Background())
|
svc.Ctx,svc.Cancel = context.WithCancel(context.Background())
|
||||||
|
|
||||||
svc.SubSysDataStore, err = datastore.Open(PATH_DATA_STORE, PATH_DATA_STORE_BACKUP + "/init.db")
|
svc.SubSysDataStore, err = datastore.Open(common.PATH_DATA_STORE, common.PATH_DATA_STORE_BACKUP + "/init.db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -181,7 +182,7 @@ func (s *Service) Start() (context.Context, context.CancelFunc) {
|
|||||||
s.SubSysDwc2ConnectWatcher.Start()
|
s.SubSysDwc2ConnectWatcher.Start()
|
||||||
s.SubSysGpio.Start()
|
s.SubSysGpio.Start()
|
||||||
s.SubSysLed.Start()
|
s.SubSysLed.Start()
|
||||||
s.SubSysRPC.StartRpcServerAndWeb("0.0.0.0", "50051", "8000", PATH_WEBROOT) //start gRPC service
|
s.SubSysRPC.StartRpcServerAndWeb("0.0.0.0", "50051", "8000", common.PATH_WEBROOT) //start gRPC service
|
||||||
log.Println("Starting TriggerAction event listener ...")
|
log.Println("Starting TriggerAction event listener ...")
|
||||||
s.SubSysTriggerActions.Start()
|
s.SubSysTriggerActions.Start()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user