更新脚本
This commit is contained in:
parent
2fd470efa1
commit
80b9412629
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -6,4 +6,6 @@ fusenrender
|
||||||
|
|
||||||
example-data
|
example-data
|
||||||
|
|
||||||
*.json
|
*.json
|
||||||
|
|
||||||
|
*.log
|
3
1.json
3
1.json
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"id": "c82cff55f2cc5cee3f71300fd8c5d953",
|
"id": "c82cff55f2cc5cee3f71300fd8c5d953",
|
||||||
"order_id": 0,
|
"order_id": 0,
|
||||||
"user_id": null,
|
"user_id": 0,
|
||||||
|
"guest_id": 0,
|
||||||
"sku_ids": [
|
"sku_ids": [
|
||||||
16,
|
16,
|
||||||
19,
|
19,
|
||||||
|
|
|
@ -36,16 +36,15 @@ type Command struct {
|
||||||
|
|
||||||
// QueueItem表示队列中的一个项
|
// QueueItem表示队列中的一个项
|
||||||
type QueueItem struct {
|
type QueueItem struct {
|
||||||
// 队列组名
|
Group string `json:"group"` // 队列组名
|
||||||
Group string `json:"group"` // 组名
|
|
||||||
|
|
||||||
Wid uint64 // 唯一标识id
|
Source string `json:"source"` // 标记业务来源
|
||||||
// 优先级
|
// 优先级
|
||||||
Priority uint32 `json:"priority"` // 处理的优先级
|
Priority uint32 `json:"priority"` // 处理的优先级
|
||||||
// 创建时间
|
// 创建时间
|
||||||
CreateAt time.Time `json:"create_at"` // 创建时间 统一utc
|
CreateAt time.Time `json:"create_at"` // 创建时间 统一utc
|
||||||
// 要排队的数据
|
// 要排队的数据
|
||||||
Data any `json:"data"` // 操作的数据结构
|
Data any `json:"render_data"` // 操作的数据结构
|
||||||
}
|
}
|
||||||
|
|
||||||
func (item *QueueItem) Encode() ([]byte, error) {
|
func (item *QueueItem) Encode() ([]byte, error) {
|
||||||
|
|
231
datajson_test.go
231
datajson_test.go
|
@ -1,119 +1,120 @@
|
||||||
package fusenrender_test
|
package fusenrender_test
|
||||||
|
|
||||||
var sendjson = `{
|
var sendjson = `{
|
||||||
"id": "c82cff55f2cc5cee3f71300fd8c5d953",
|
"id": "c82cff55f2cc5cee3f71300fd8c5d953",
|
||||||
"order_id": 0,
|
"order_id": 0,
|
||||||
"user_id": null,
|
"user_id": 0,
|
||||||
"sku_ids": [
|
"guest_id": 0,
|
||||||
16,
|
"sku_ids": [
|
||||||
19,
|
16,
|
||||||
25,
|
19,
|
||||||
13
|
25,
|
||||||
],
|
13
|
||||||
"tids": [
|
],
|
||||||
"FSN-PPBX-1",
|
"tids": [
|
||||||
"FSN-PLUP-4",
|
"FSN-PPBX-1",
|
||||||
"FSN-PPCCT-2"
|
"FSN-PLUP-4",
|
||||||
],
|
"FSN-PPCCT-2"
|
||||||
"data": [
|
],
|
||||||
{
|
"data": [
|
||||||
"light": 2,
|
{
|
||||||
"refletion": -1,
|
"light": 2,
|
||||||
"scale": "22",
|
"refletion": -1,
|
||||||
"sku_id": 25,
|
"scale": "22",
|
||||||
"tid": "FSN-PPBX-1",
|
"sku_id": 25,
|
||||||
"rotation": "5.4,-41,-4.7",
|
"tid": "FSN-PPBX-1",
|
||||||
"filePath": "",
|
"rotation": "5.4,-41,-4.7",
|
||||||
"data": [
|
"filePath": "",
|
||||||
{
|
"data": [
|
||||||
"name": "model",
|
{
|
||||||
"data": "0,https:\/\/fusenh5.kayue.cn:8011\/storage\/test\/final_JntYgQf85p_temp.png,FSN-PPBX-1_MaskMap,FSN-PPBX-1_Normal,FSN-PPBX-1_BaseMap",
|
"name": "model",
|
||||||
"type": "other",
|
"data": "0,https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/bfc1dcc0f1a9beb49b2182d6c94de6f4bb648cd7b82be75b2e24e0bed3bef798,FSN-PPBX-1_MaskMap,FSN-PPBX-1_Normal,FSN-PPBX-1_BaseMap",
|
||||||
"layer": "0",
|
"type": "other",
|
||||||
"is_update": 1,
|
"layer": "0",
|
||||||
"mode": "Opaque"
|
"is_update": 1,
|
||||||
},
|
"mode": "Opaque"
|
||||||
{
|
},
|
||||||
"name": "shadow",
|
{
|
||||||
"data": "0,FSN-PPBX-1,0,0,0",
|
"name": "shadow",
|
||||||
"type": "other",
|
"data": "0,FSN-PPBX-1,0,0,0",
|
||||||
"layer": "0",
|
"type": "other",
|
||||||
"is_update": 0,
|
"layer": "0",
|
||||||
"mode": "Fade"
|
"is_update": 0,
|
||||||
}
|
"mode": "Fade"
|
||||||
]
|
}
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"light": 8,
|
{
|
||||||
"refletion": -1,
|
"light": 8,
|
||||||
"scale": "12.5",
|
"refletion": -1,
|
||||||
"sku_id": 19,
|
"scale": "12.5",
|
||||||
"tid": "FSN-PPCCT-2",
|
"sku_id": 19,
|
||||||
"rotation": "-2,25.5,-1",
|
"tid": "FSN-PPCCT-2",
|
||||||
"filePath": "",
|
"rotation": "-2,25.5,-1",
|
||||||
"data": [
|
"filePath": "",
|
||||||
{
|
"data": [
|
||||||
"name": "model",
|
{
|
||||||
"data": "0,https:\/\/fusenh5.kayue.cn:8011\/storage\/test\/final_xNf7MC38vc_temp.png,FSN-PPCCT-2_MaskMap,FSN-PPCCT-2_Normal,FSN-PPCCT-2_BaseMap",
|
"name": "model",
|
||||||
"type": "other",
|
"data": "0,https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/bfc1dcc0f1a9beb49b2182d6c94de6f4bb648cd7b82be75b2e24e0bed3bef798,FSN-PPCCT-2_MaskMap,FSN-PPCCT-2_Normal,FSN-PPCCT-2_BaseMap",
|
||||||
"layer": "0",
|
"type": "other",
|
||||||
"is_update": 1,
|
"layer": "0",
|
||||||
"mode": "Opaque"
|
"is_update": 1,
|
||||||
},
|
"mode": "Opaque"
|
||||||
{
|
},
|
||||||
"name": "shadow",
|
{
|
||||||
"data": "0,FSN-PPCCT-2,0,0,0",
|
"name": "shadow",
|
||||||
"type": "other",
|
"data": "0,FSN-PPCCT-2,0,0,0",
|
||||||
"layer": "0",
|
"type": "other",
|
||||||
"is_update": 0,
|
"layer": "0",
|
||||||
"mode": "Fade"
|
"is_update": 0,
|
||||||
},
|
"mode": "Fade"
|
||||||
{
|
},
|
||||||
"name": "model_P",
|
{
|
||||||
"data": "0,FSN-PPCCT-2-P,FSN-PPCCT-2-P_MaskMap,FSN-PPCCT-2-P_Normal,FSN-PPCCT-2-P_BaseMap",
|
"name": "model_P",
|
||||||
"type": "other",
|
"data": "0,FSN-PPCCT-2-P,FSN-PPCCT-2-P_MaskMap,FSN-PPCCT-2-P_Normal,FSN-PPCCT-2-P_BaseMap",
|
||||||
"layer": "0",
|
"type": "other",
|
||||||
"is_update": 0,
|
"layer": "0",
|
||||||
"mode": "Fade"
|
"is_update": 0,
|
||||||
}
|
"mode": "Fade"
|
||||||
]
|
}
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"light": 7,
|
{
|
||||||
"refletion": 7,
|
"light": 7,
|
||||||
"scale": "14",
|
"refletion": 7,
|
||||||
"sku_id": 16,
|
"scale": "14",
|
||||||
"tid": "FSN-PLUP-4",
|
"sku_id": 16,
|
||||||
"rotation": "0,0,0",
|
"tid": "FSN-PLUP-4",
|
||||||
"filePath": "",
|
"rotation": "0,0,0",
|
||||||
"data": [
|
"filePath": "",
|
||||||
{
|
"data": [
|
||||||
"name": "model",
|
{
|
||||||
"data": "0,https:\/\/fusenh5.kayue.cn:8011\/storage\/test\/final_ImDCgYaw9o_temp.png,FSN-PLUP-4_MaskMap,FSN-PLUP-4_Normal,FSN-PLUP-4_BaseMap",
|
"name": "model",
|
||||||
"type": "other",
|
"data": "0,https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/bfc1dcc0f1a9beb49b2182d6c94de6f4bb648cd7b82be75b2e24e0bed3bef798,FSN-PLUP-4_MaskMap,FSN-PLUP-4_Normal,FSN-PLUP-4_BaseMap",
|
||||||
"layer": "0",
|
"type": "other",
|
||||||
"is_update": 1,
|
"layer": "0",
|
||||||
"mode": "Opaque"
|
"is_update": 1,
|
||||||
},
|
"mode": "Opaque"
|
||||||
{
|
},
|
||||||
"name": "shadow",
|
{
|
||||||
"data": "0,FSN-PLUP-4,0,0,0",
|
"name": "shadow",
|
||||||
"type": "other",
|
"data": "0,FSN-PLUP-4,0,0,0",
|
||||||
"layer": "0",
|
"type": "other",
|
||||||
"is_update": 0,
|
"layer": "0",
|
||||||
"mode": "Fade"
|
"is_update": 0,
|
||||||
},
|
"mode": "Fade"
|
||||||
{
|
},
|
||||||
"name": "model_P",
|
{
|
||||||
"data": "0,FSN-PLUP-4-P,FSN-PLUP-4-P_MaskMap,FSN-PLUP-4-P_Normal,FSN-PLUP-4-P_BaseMap",
|
"name": "model_P",
|
||||||
"type": "other",
|
"data": "0,FSN-PLUP-4-P,FSN-PLUP-4-P_MaskMap,FSN-PLUP-4-P_Normal,FSN-PLUP-4-P_BaseMap",
|
||||||
"layer": "0",
|
"type": "other",
|
||||||
"is_update": 0,
|
"layer": "0",
|
||||||
"mode": "Opaque"
|
"is_update": 0,
|
||||||
}
|
"mode": "Opaque"
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
],
|
}
|
||||||
"is_thousand_face": 0,
|
],
|
||||||
"folder": ""
|
"is_thousand_face": 0,
|
||||||
|
"folder": ""
|
||||||
}`
|
}`
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
serverid: 1
|
serverid: 1
|
||||||
host: "localhost"
|
host: "0.0.0.0"
|
||||||
port: 5050
|
port: 5050
|
||||||
cluster: [ "localhost:5050","localhost:5051","localhost:5052" ]
|
cluster: [ "0.0.0.0:5050","0.0.0.0:5051","0.0.0.0:5052" ]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
serverid: 2
|
serverid: 2
|
||||||
host: "localhost"
|
host: "0.0.0.0"
|
||||||
port: 5051
|
port: 5051
|
||||||
cluster: [ "localhost:5050","localhost:5051","localhost:5052" ]
|
cluster: [ "0.0.0.0:5050","0.0.0.0:5051","0.0.0.0:5052" ]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
serverid: 3
|
serverid: 3
|
||||||
host: "localhost"
|
host: "0.0.0.0"
|
||||||
port: 5052
|
port: 5052
|
||||||
cluster: [ "localhost:5050","localhost:5051","localhost:5052" ]
|
cluster: [ "0.0.0.0:5050","0.0.0.0:5051","0.0.0.0:5052" ]
|
||||||
|
|
2
main.go
2
main.go
|
@ -25,7 +25,7 @@ var DequeueHandler = triggered.RegisterExecute(func(params *triggered.Params[boo
|
||||||
cs := stateClient.GetNoOPSession()
|
cs := stateClient.GetNoOPSession()
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
|
|
||||||
item, err := stateClient.PopItem(cs, "test")
|
item, err := stateClient.PopItem(cs, "unity3d")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
break
|
break
|
||||||
|
|
27
main/main.go
Normal file
27
main/main.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"fusenrender"
|
||||||
|
)
|
||||||
|
|
||||||
|
var configEnv string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.StringVar(&configEnv, "etc", "a", "配置环境(etc文件)")
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
configFile := fmt.Sprintf("../etc/etc_%s.yaml", configEnv)
|
||||||
|
|
||||||
|
svc, err := fusenrender.LoadConfig(configFile)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fusenrender.StartNode(svc)
|
||||||
|
}
|
15
main/start.sh
Executable file
15
main/start.sh
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
for env in a b c; do
|
||||||
|
|
||||||
|
# 启动screen
|
||||||
|
screen_name="screen_$env"
|
||||||
|
screen -dmS $screen_name
|
||||||
|
|
||||||
|
# 构造日志名
|
||||||
|
log="log_$env.log"
|
||||||
|
|
||||||
|
# 使用go run 重定向日志
|
||||||
|
screen -S $screen_name -X stuff "go run main.go -env $env >> $log 2>&1\n"
|
||||||
|
|
||||||
|
done
|
15
main/stop.sh
Executable file
15
main/stop.sh
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
for env in a b c; do
|
||||||
|
|
||||||
|
# 构造screen会话名
|
||||||
|
screen_name="screen_$env"
|
||||||
|
|
||||||
|
# 使用-S参数直接停止指定会话
|
||||||
|
screen -S $screen_name -X quit
|
||||||
|
|
||||||
|
# 或者使用PID停止
|
||||||
|
# screen_pid=$(screen -list | grep $screen_name | awk '{print $1}')
|
||||||
|
# kill $screen_pid
|
||||||
|
|
||||||
|
done
|
10
websocket.go
10
websocket.go
|
@ -24,9 +24,9 @@ var upgrader = websocket.Upgrader{
|
||||||
}
|
}
|
||||||
|
|
||||||
func HttpListen(ns *dragonboat.NodeHost, port int) {
|
func HttpListen(ns *dragonboat.NodeHost, port int) {
|
||||||
http.HandleFunc("/api/render/render_notify", callbackHandler)
|
// http.HandleFunc("/api/render/render_notify", callbackHandler)
|
||||||
http.HandleFunc("/api/queue/push", pushRenderTaskHandler)
|
http.HandleFunc("/api/render/queue/push", pushRenderTaskHandler)
|
||||||
http.HandleFunc("/ws/pop/queue", queueHandler)
|
http.HandleFunc("/api/ws/render/queue/pop", queueHandler)
|
||||||
|
|
||||||
log.Printf(":%d", port)
|
log.Printf(":%d", port)
|
||||||
http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
|
http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
|
||||||
|
@ -162,7 +162,7 @@ func (cli *StateClient) PushItem(cs *client.Session, item *QueueItem) {
|
||||||
cs = cli.GetNoOPSession()
|
cs = cli.GetNoOPSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := &CmdEnqueue{Command: Command{Group: "test"}}
|
cmd := &CmdEnqueue{Command: Command{Group: "unity3d"}}
|
||||||
cmd.Item = item
|
cmd.Item = item
|
||||||
data, err := FsPasser.PackToBytes(cmd)
|
data, err := FsPasser.PackToBytes(cmd)
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ func (cli *StateClient) PopItem(cs *client.Session, group string) (*QueueItem, e
|
||||||
cs = cli.GetNoOPSession()
|
cs = cli.GetNoOPSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := &CmdDequeue{Command{Group: "test"}}
|
cmd := &CmdDequeue{Command{Group: "unity3d"}}
|
||||||
data, err := FsPasser.PackToBytes(cmd)
|
data, err := FsPasser.PackToBytes(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
|
|
@ -19,7 +19,6 @@ func TestWebsocketA(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fusenrender.StartNode(svc)
|
fusenrender.StartNode(svc)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWebsocketB(t *testing.T) {
|
func TestWebsocketB(t *testing.T) {
|
||||||
|
@ -27,9 +26,7 @@ func TestWebsocketB(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fusenrender.StartNode(svc)
|
fusenrender.StartNode(svc)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWebsocketC(t *testing.T) {
|
func TestWebsocketC(t *testing.T) {
|
||||||
|
@ -37,9 +34,7 @@ func TestWebsocketC(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fusenrender.StartNode(svc)
|
fusenrender.StartNode(svc)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var addr = "localhost:4050"
|
var addr = "localhost:4050"
|
||||||
|
@ -54,12 +49,12 @@ func TestWebsocketCient(t *testing.T) {
|
||||||
C := time.NewTicker(time.Second * 5)
|
C := time.NewTicker(time.Second * 5)
|
||||||
for range C.C {
|
for range C.C {
|
||||||
item := fusenrender.QueueItem{
|
item := fusenrender.QueueItem{
|
||||||
Group: "test",
|
Group: "unity3d",
|
||||||
Wid: fusenrender.UidCreater.Get(),
|
|
||||||
CreateAt: time.Now(),
|
CreateAt: time.Now(),
|
||||||
Data: sendjson,
|
Data: sendjson,
|
||||||
}
|
}
|
||||||
r, err := requests.Post(fmt.Sprintf("http://%s/api/queue/push", addr)).SetBodyJson(item).Execute()
|
r, err := requests.Post(fmt.Sprintf("http://%s/api/render/queue/push", addr)).SetBodyJson(item).Execute()
|
||||||
log.Println(r, err)
|
log.Println(r, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user