feat(controller): added copy by server only currently
This commit is contained in:
35
controller/update_channel.go
Normal file
35
controller/update_channel.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
socketio "github.com/googollee/go-socket.io"
|
||||
)
|
||||
|
||||
func registerUpdateChannel(server *socketio.Server) {
|
||||
|
||||
server.OnEvent("/", "subscribe:update", func(s socketio.Conn) {
|
||||
s.Join("update")
|
||||
s.Emit("updateLogs", "👋 Subscribed to update channel")
|
||||
fmt.Println("📺", s.ID(), "joined update room")
|
||||
})
|
||||
|
||||
// copy files based on the target passed over
|
||||
server.OnEvent("/", "update", func(s socketio.Conn, target string) {
|
||||
server.BroadcastToRoom("/", "update", "updateLogs",
|
||||
fmt.Sprintf("🚀 Copying latest build to %v", target))
|
||||
copyBuild(server, target)
|
||||
})
|
||||
|
||||
// update the server
|
||||
// server.OnEvent("/", "update", func(s socketio.Conn, target string) {
|
||||
// msg := fmt.Sprintf("🔧 Running updateServer on: %s", target)
|
||||
// server.BroadcastToRoom("/update", "update", "updateLogs", msg)
|
||||
|
||||
// })
|
||||
|
||||
server.OnEvent("/", "unsubscribe:update", func(s socketio.Conn) {
|
||||
s.Leave("update")
|
||||
s.Emit("updateLogs", "👋 Unsubscribed from update logs")
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user