commit
21d924ffb4
@ -0,0 +1 @@
|
|||||||
|
{"pid":36728}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
case $3 in
|
||||||
|
"")
|
||||||
|
goarch="amd64"
|
||||||
|
releasePath="x86_64"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"arm")
|
||||||
|
goarch="arm"
|
||||||
|
releasePath="arm"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"arm64")
|
||||||
|
goarch="arm64"
|
||||||
|
releasePath="arm64"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"loong64")
|
||||||
|
goarch="loong64"
|
||||||
|
releasePath="loong64"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo '目标 ' $3 ' 无法编译'
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
buildfile=$1
|
||||||
|
|
||||||
|
|
||||||
|
case $2 in
|
||||||
|
"linux") echo '交叉编译目标为linux+'$goarch
|
||||||
|
echo "CGO_ENABLED=0 GOOS=linux GOARCH="$goarch" go build "$1
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=$goarch go build -o ./"${buildfile%%.*}-"$releasePath $1
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"windows") echo '交叉编译目标为windows+'$goarch
|
||||||
|
echo "CGO_ENABLED=0 GOOS=windows GOARCH="$goarch" go build "$1
|
||||||
|
CGO_ENABLED=0 GOOS=windows GOARCH=$goarch go build -o ././"${buildfile%%.*}-"$releasePath".exe" $1
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"darwin") echo '交叉编译目标为maxos+'$goarch
|
||||||
|
echo "CGO_ENABLED=0 GOOS=darwin GOARCH="$goarch" go build "$1
|
||||||
|
CGO_ENABLED=0 GOOS=darwin GOARCH=$goarch go build -o ./"${buildfile%%.*}-"$releasePath $1
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo '参数不正确:'$goarch
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo '脚本执行结束...'
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"serverport":"9001"
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"DbType":"mysql",
|
||||||
|
"IsMaster":true,
|
||||||
|
"Dsn":"root:Password1!@tcp(mysql-a.fanhaninfo.test:3306)/dev_digital?charset=utf8mb4",
|
||||||
|
"sqlMaxIdleConns":100,
|
||||||
|
"sqlMaxOpenConns":100,
|
||||||
|
"sqlLogLevel":2
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"DbType":"mysql",
|
||||||
|
"IsMaster":true,
|
||||||
|
"Dsn":"root:12345678@tcp(127.0.0.1:3306)/fushouxian?charset=utf8mb4",
|
||||||
|
"sqlMaxIdleConns":1,
|
||||||
|
"sqlMaxOpenConns":1,
|
||||||
|
"sqlLogLevel":2
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"rpa_url": "http://172.0.0.19:19005",
|
||||||
|
"username": "admin",
|
||||||
|
"password": "123"
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"Priority":100,
|
||||||
|
"ModuleName":"go",
|
||||||
|
"ServerUrls":[
|
||||||
|
"wss://shop.ruixininfo.com/websocket/jsonrpc"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
_ "src/init"
|
||||||
|
|
||||||
|
"github.com/towgo/towgo/dao/basedboperat"
|
||||||
|
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
|
||||||
|
"github.com/towgo/towgo/lib/processmanager"
|
||||||
|
"github.com/towgo/towgo/lib/system"
|
||||||
|
"github.com/towgo/towgo/towgo"
|
||||||
|
)
|
||||||
|
|
||||||
|
var appName string = "fushouxian-server"
|
||||||
|
var appVersion string = "1.0.0"
|
||||||
|
|
||||||
|
var basePath = system.GetPathOfProgram()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
//初始化xorm数据库驱动
|
||||||
|
var dbconfig []xormDriver.DsnConfig
|
||||||
|
system.ScanConfigJson(basePath+"/config/dbconfig.json", &dbconfig)
|
||||||
|
xormDriver.New(dbconfig)
|
||||||
|
|
||||||
|
//设定默认orm引擎
|
||||||
|
err := basedboperat.SetOrmEngine("xorm")
|
||||||
|
if err != nil {
|
||||||
|
log.Print(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
func main() {
|
||||||
|
pm := processmanager.GetManager()
|
||||||
|
for k, v := range os.Args {
|
||||||
|
switch v {
|
||||||
|
case "start":
|
||||||
|
if k == 1 {
|
||||||
|
if pm.Start() {
|
||||||
|
log.Print("启动成功")
|
||||||
|
start()
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
log.Print("启动失败:" + pm.Error.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "restart":
|
||||||
|
if k == 1 {
|
||||||
|
if pm.ReStart() {
|
||||||
|
log.Print("重启成功")
|
||||||
|
start()
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
log.Print("重启失败:" + pm.Error.Error())
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "stop":
|
||||||
|
if k == 1 {
|
||||||
|
if pm.Stop() {
|
||||||
|
log.Print("程序停止成功")
|
||||||
|
} else {
|
||||||
|
log.Print("程序停止失败:程序没有运行")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "version":
|
||||||
|
if k == 1 {
|
||||||
|
fmt.Print(appName + ":" + appVersion + "\n")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Print("参数传递错误,有效参数如下:\n" + os.Args[0] + " start | stop | reload | stop")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func start() {
|
||||||
|
|
||||||
|
moduleClientInit()
|
||||||
|
|
||||||
|
conf := struct {
|
||||||
|
Serverport string `json:"serverport"`
|
||||||
|
}{}
|
||||||
|
system.ScanConfigJson(basePath+"/config/config.json", &conf)
|
||||||
|
|
||||||
|
http.HandleFunc("/jsonrpc", towgo.HttpHandller)
|
||||||
|
|
||||||
|
log.Print("http服务运行中:0.0.0.0:" + conf.Serverport + "\n")
|
||||||
|
http.ListenAndServe("0.0.0.0:"+conf.Serverport, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func moduleClientInit() {
|
||||||
|
var node towgo.EdgeServerNodeConfig
|
||||||
|
system.ScanConfigJson(basePath+"config/togocdn.client.config.json", &node)
|
||||||
|
node.Methods = towgo.GetMethods()
|
||||||
|
node.ModuleName = appName
|
||||||
|
for _, v := range node.ServerUrls {
|
||||||
|
node.ServerUrl = v
|
||||||
|
client := towgo.NewEdgeServerNode(node)
|
||||||
|
client.Connect()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1 +1 @@
|
|||||||
{"pid":33859}
|
{"pid":36728}
|
||||||
Loading…
Reference in new issue