diff --git a/dsAutoCode/Controller/ProtoController/Template/Service.template b/dsAutoCode/Controller/ProtoController/Template/Service.template index 796282da..1af647c7 100644 --- a/dsAutoCode/Controller/ProtoController/Template/Service.template +++ b/dsAutoCode/Controller/ProtoController/Template/Service.template @@ -1,18 +1,21 @@ -/** -功能:{{.description}} -作者:{{.authorName}} -时间:{{.currenttime}} -*/ -func {{.interfaceName}}({{.Parameters}}) (*{{.tableName}}Proto.Reply, error) { - //1、准备动作:连接服务器 - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - conn := GRpcUtil.GetConnection() - //2、业务传参 - c := {{.tableName}}Proto.New{{.tableName}}ManageClient(conn) - Reply, err := c.{{.interfaceName}}(ctx, &{{.tableName}}Proto.{{.argPrefix}}{{.RpcServiceParameters}}) - if err != nil { - LogUtil.Error("{{.description}}错误: ", err.Error()) - } - return Reply, err -} +/** +功能:{{.description}} +作者:{{.authorName}} +时间:{{.currenttime}} +*/ +func {{.interfaceName}}({{.Parameters}}) (*{{.tableName}}Proto.Reply, error) { + //1、准备动作:连接服务器 + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + conn := GRpcUtil.GetConnection() + if conn == nil { + return nil, errors.New("RPC服务未启动!") + } + //2、业务传参 + c := {{.tableName}}Proto.New{{.tableName}}ManageClient(conn) + Reply, err := c.{{.interfaceName}}(ctx, &{{.tableName}}Proto.{{.argPrefix}}{{.RpcServiceParameters}}) + if err != nil { + LogUtil.Error("{{.description}}错误: ", err.Error()) + } + return Reply, err +} diff --git a/dsBaseRpc/Shell/debug.sh b/dsBaseRpc/Shell/debug.sh index 325067af..bdc11751 100644 --- a/dsBaseRpc/Shell/debug.sh +++ b/dsBaseRpc/Shell/debug.sh @@ -10,5 +10,5 @@ chmod +x dsBaseRpc # 运行为后台进程 cd /usr/local/dsMin/dsBaseRpc && -# 使用dlv方便远程调试 -dlv --listen=:2345 --headless=true --api-version=2 exec ./dsBaseRpc + +/usr/local/dsMin/dsBaseRpc/dsBaseRpc diff --git a/dsBaseRpc/Shell/remote.sh b/dsBaseRpc/Shell/remote.sh new file mode 100644 index 00000000..21c4f418 --- /dev/null +++ b/dsBaseRpc/Shell/remote.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# 先杀掉内存中的进程 +kill -9 `pgrep -f dsBaseRpc` 2>/dev/null +# 休息3秒 +sleep 3 + +cd /usr/local/dsMin/dsBaseRpc +chmod +x dsBaseRpc + +# 运行为后台进程 +cd /usr/local/dsMin/dsBaseRpc && + +# 使用dlv方便远程调试 +dlv --listen=:2345 --headless=true --api-version=2 exec ./dsBaseRpc diff --git a/dsBaseRpc/Tools/Distribute.go b/dsBaseRpc/Tools/Distribute.go index 4671fe34..5464180f 100644 --- a/dsBaseRpc/Tools/Distribute.go +++ b/dsBaseRpc/Tools/Distribute.go @@ -35,7 +35,7 @@ func main() { //执行SSH命令行,授权 cli.Run("chmod +x /usr/local/dsMin/dsBaseRpc/dsBaseRpc") cli.Run("chmod +x /usr/local/dsMin/dsBaseRpc/start.sh") - cli.Run("chmod +x /usr/local/dsMin/dsBaseRpc/debug.sh") + cli.Run("chmod +x /usr/local/dsMin/dsBaseRpc/remote.sh") cli.Run("chmod +x /usr/local/dsMin/dsBaseRpc/stop.sh") //启动 cli.Run("cd /usr/local/dsMin/dsBaseRpc && ./start.sh")