更新脚本

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

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ fusenrender
example-data
*.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

@ -3,7 +3,8 @@ package fusenrender_test
var sendjson = `{
"id": "c82cff55f2cc5cee3f71300fd8c5d953",
"order_id": 0,
"user_id": null,
"user_id": 0,
"guest_id": 0,
"sku_ids": [
16,
19,
@ -27,7 +28,7 @@ var sendjson = `{
"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",
"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,
@ -54,7 +55,7 @@ var sendjson = `{
"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",
"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,
@ -89,7 +90,7 @@ var sendjson = `{
"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",
"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,

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)
}
}()