更新脚本

This commit is contained in:
eson 2023-08-16 11:42:49 +08:00
parent 2fd470efa1
commit 80b9412629
13 changed files with 196 additions and 141 deletions

4
.gitignore vendored
View File

@ -6,4 +6,6 @@ fusenrender
example-data
*.json
*.json
*.log

3
1.json
View File

@ -1,7 +1,8 @@
{
"id": "c82cff55f2cc5cee3f71300fd8c5d953",
"order_id": 0,
"user_id": null,
"user_id": 0,
"guest_id": 0,
"sku_ids": [
16,
19,

View File

@ -36,16 +36,15 @@ type Command struct {
// QueueItem表示队列中的一个项
type QueueItem struct {
// 队列组名
Group string `json:"group"` // 组名
Group string `json:"group"` // 队列组名
Wid uint64 // 唯一标识id
Source string `json:"source"` // 标记业务来源
// 优先级
Priority uint32 `json:"priority"` // 处理的优先级
// 创建时间
CreateAt time.Time `json:"create_at"` // 创建时间 统一utc
// 要排队的数据
Data any `json:"data"` // 操作的数据结构
Data any `json:"render_data"` // 操作的数据结构
}
func (item *QueueItem) Encode() ([]byte, error) {

View File

@ -1,119 +1,120 @@
package fusenrender_test
var sendjson = `{
"id": "c82cff55f2cc5cee3f71300fd8c5d953",
"order_id": 0,
"user_id": null,
"sku_ids": [
16,
19,
25,
13
],
"tids": [
"FSN-PPBX-1",
"FSN-PLUP-4",
"FSN-PPCCT-2"
],
"data": [
{
"light": 2,
"refletion": -1,
"scale": "22",
"sku_id": 25,
"tid": "FSN-PPBX-1",
"rotation": "5.4,-41,-4.7",
"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",
"type": "other",
"layer": "0",
"is_update": 1,
"mode": "Opaque"
},
{
"name": "shadow",
"data": "0,FSN-PPBX-1,0,0,0",
"type": "other",
"layer": "0",
"is_update": 0,
"mode": "Fade"
}
]
},
{
"light": 8,
"refletion": -1,
"scale": "12.5",
"sku_id": 19,
"tid": "FSN-PPCCT-2",
"rotation": "-2,25.5,-1",
"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",
"type": "other",
"layer": "0",
"is_update": 1,
"mode": "Opaque"
},
{
"name": "shadow",
"data": "0,FSN-PPCCT-2,0,0,0",
"type": "other",
"layer": "0",
"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",
"type": "other",
"layer": "0",
"is_update": 0,
"mode": "Fade"
}
]
},
{
"light": 7,
"refletion": 7,
"scale": "14",
"sku_id": 16,
"tid": "FSN-PLUP-4",
"rotation": "0,0,0",
"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",
"type": "other",
"layer": "0",
"is_update": 1,
"mode": "Opaque"
},
{
"name": "shadow",
"data": "0,FSN-PLUP-4,0,0,0",
"type": "other",
"layer": "0",
"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",
"type": "other",
"layer": "0",
"is_update": 0,
"mode": "Opaque"
}
]
}
],
"is_thousand_face": 0,
"folder": ""
"id": "c82cff55f2cc5cee3f71300fd8c5d953",
"order_id": 0,
"user_id": 0,
"guest_id": 0,
"sku_ids": [
16,
19,
25,
13
],
"tids": [
"FSN-PPBX-1",
"FSN-PLUP-4",
"FSN-PPCCT-2"
],
"data": [
{
"light": 2,
"refletion": -1,
"scale": "22",
"sku_id": 25,
"tid": "FSN-PPBX-1",
"rotation": "5.4,-41,-4.7",
"filePath": "",
"data": [
{
"name": "model",
"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",
"type": "other",
"layer": "0",
"is_update": 1,
"mode": "Opaque"
},
{
"name": "shadow",
"data": "0,FSN-PPBX-1,0,0,0",
"type": "other",
"layer": "0",
"is_update": 0,
"mode": "Fade"
}
]
},
{
"light": 8,
"refletion": -1,
"scale": "12.5",
"sku_id": 19,
"tid": "FSN-PPCCT-2",
"rotation": "-2,25.5,-1",
"filePath": "",
"data": [
{
"name": "model",
"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",
"type": "other",
"layer": "0",
"is_update": 1,
"mode": "Opaque"
},
{
"name": "shadow",
"data": "0,FSN-PPCCT-2,0,0,0",
"type": "other",
"layer": "0",
"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",
"type": "other",
"layer": "0",
"is_update": 0,
"mode": "Fade"
}
]
},
{
"light": 7,
"refletion": 7,
"scale": "14",
"sku_id": 16,
"tid": "FSN-PLUP-4",
"rotation": "0,0,0",
"filePath": "",
"data": [
{
"name": "model",
"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",
"type": "other",
"layer": "0",
"is_update": 1,
"mode": "Opaque"
},
{
"name": "shadow",
"data": "0,FSN-PLUP-4,0,0,0",
"type": "other",
"layer": "0",
"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",
"type": "other",
"layer": "0",
"is_update": 0,
"mode": "Opaque"
}
]
}
],
"is_thousand_face": 0,
"folder": ""
}`

View File

@ -1,4 +1,4 @@
serverid: 1
host: "localhost"
host: "0.0.0.0"
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" ]

View File

@ -1,4 +1,4 @@
serverid: 2
host: "localhost"
host: "0.0.0.0"
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" ]

View File

@ -1,4 +1,4 @@
serverid: 3
host: "localhost"
host: "0.0.0.0"
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" ]

View File

@ -25,7 +25,7 @@ var DequeueHandler = triggered.RegisterExecute(func(params *triggered.Params[boo
cs := stateClient.GetNoOPSession()
for i := 0; ; i++ {
item, err := stateClient.PopItem(cs, "test")
item, err := stateClient.PopItem(cs, "unity3d")
if err != nil {
log.Println(err)
break

27
main/main.go Normal file
View 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
View 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
View 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

View File

@ -24,9 +24,9 @@ var upgrader = websocket.Upgrader{
}
func HttpListen(ns *dragonboat.NodeHost, port int) {
http.HandleFunc("/api/render/render_notify", callbackHandler)
http.HandleFunc("/api/queue/push", pushRenderTaskHandler)
http.HandleFunc("/ws/pop/queue", queueHandler)
// http.HandleFunc("/api/render/render_notify", callbackHandler)
http.HandleFunc("/api/render/queue/push", pushRenderTaskHandler)
http.HandleFunc("/api/ws/render/queue/pop", queueHandler)
log.Printf(":%d", port)
http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
@ -162,7 +162,7 @@ func (cli *StateClient) PushItem(cs *client.Session, item *QueueItem) {
cs = cli.GetNoOPSession()
}
cmd := &CmdEnqueue{Command: Command{Group: "test"}}
cmd := &CmdEnqueue{Command: Command{Group: "unity3d"}}
cmd.Item = item
data, err := FsPasser.PackToBytes(cmd)
@ -185,7 +185,7 @@ func (cli *StateClient) PopItem(cs *client.Session, group string) (*QueueItem, e
cs = cli.GetNoOPSession()
}
cmd := &CmdDequeue{Command{Group: "test"}}
cmd := &CmdDequeue{Command{Group: "unity3d"}}
data, err := FsPasser.PackToBytes(cmd)
if err != nil {
log.Println(err)

View File

@ -19,7 +19,6 @@ func TestWebsocketA(t *testing.T) {
}
fusenrender.StartNode(svc)
}
func TestWebsocketB(t *testing.T) {
@ -27,9 +26,7 @@ func TestWebsocketB(t *testing.T) {
if err != nil {
panic(err)
}
fusenrender.StartNode(svc)
}
func TestWebsocketC(t *testing.T) {
@ -37,9 +34,7 @@ func TestWebsocketC(t *testing.T) {
if err != nil {
panic(err)
}
fusenrender.StartNode(svc)
}
var addr = "localhost:4050"
@ -54,12 +49,12 @@ func TestWebsocketCient(t *testing.T) {
C := time.NewTicker(time.Second * 5)
for range C.C {
item := fusenrender.QueueItem{
Group: "test",
Wid: fusenrender.UidCreater.Get(),
Group: "unity3d",
CreateAt: time.Now(),
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)
}
}()