diff --git a/app.go b/app.go
index 8346eab..687ca80 100644
--- a/app.go
+++ b/app.go
@@ -2,10 +2,30 @@ package main
import (
"context"
+ "encoding/json"
"fmt"
- // "github.com/wailsapp/wails/v2/pkg/runtime"
+ "os"
+
+ "github.com/estebangarcia21/subprocess"
+ "github.com/wailsapp/wails/v2/pkg/runtime"
)
+type Server struct {
+ Name string `json:"name"`
+ Dir string `json:"dir"`
+ Cmd string `json:"cmd"`
+ Url string `json:"url"`
+ Port string `json:"port"`
+ Run string `json:"run"`
+}
+
+func (s *Server) Start() {
+ os.Chdir(s.Dir)
+ //s := subprocess.New(".\\"+name+".exe")
+ p := subprocess.New(s.Cmd)
+ p.ExecAsync()
+}
+
// App struct
type App struct {
ctx context.Context
@@ -27,3 +47,27 @@ func (a *App) startup(ctx context.Context) {
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time!", name)
}
+
+func startLocalServer(name, dir, cmd string) {
+ //os.Chdir("d:\\projects\\" + name);
+ os.Chdir(dir)
+ //s := subprocess.New(".\\"+name+".exe")
+ s := subprocess.New(cmd)
+ s.ExecAsync()
+}
+
+// StartServer - запускает сервер на выполение
+func (a *App) StartServer(s string) string {
+ runtime.LogInfo(a.ctx, s)
+ var server Server
+ if err := json.Unmarshal([]byte(s), &server); err != nil {
+ runtime.LogInfo(a.ctx, err.Error())
+ }
+ runtime.LogInfo(a.ctx, fmt.Sprintf("server: %v", server))
+
+ server.Url = fmt.Sprintf("http://localhost:%s", server.Port)
+ server.Start()
+ runtime.BrowserOpenURL(a.ctx, server.Url)
+
+ return "starting server"
+}
diff --git a/frontend/index.html b/frontend/index.html
index 641e67b..daee15f 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -3,6 +3,7 @@
+
server
diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte
index d13b95a..1a39684 100644
--- a/frontend/src/App.svelte
+++ b/frontend/src/App.svelte
@@ -1,7 +1,10 @@
-
-
- {resultText}
- Проверка
-
-
-
-
+
+ СЕРВЕРА
+ {#each servers as server}
+
+
+
+
+
+ {/each}
diff --git a/frontend/src/servers.js b/frontend/src/servers.js
new file mode 100644
index 0000000..1fd0df4
--- /dev/null
+++ b/frontend/src/servers.js
@@ -0,0 +1,32 @@
+const servers = [
+ {
+ name: "books-web",
+ dir: "d:\\projects\\books-web",
+ cmd: ".\\books-web.exe",
+ port: "3000",
+ run: "idle"
+ },
+ {
+ name: "nano-tw",
+ dir: "d:\\projects\\nano-tw",
+ cmd: ".\\nano-tw.exe",
+ port: "4321",
+ run: "idle"
+ },
+ {
+ name: "trans-web",
+ dir: "d:\\projects\\trans-web",
+ cmd: ".\\trans-web.exe",
+ port: "4322",
+ run: "idle"
+ },
+ {
+ name: "stem",
+ dir: "d:\\projects\\stem",
+ cmd: ".\\stem.exe",
+ port: "4323",
+ run: "idle"
+ },
+];
+
+export default servers;
\ No newline at end of file
diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts
index 02a3bb9..9d7b500 100644
--- a/frontend/wailsjs/go/main/App.d.ts
+++ b/frontend/wailsjs/go/main/App.d.ts
@@ -2,3 +2,5 @@
// This file is automatically generated. DO NOT EDIT
export function Greet(arg1:string):Promise;
+
+export function StartServer(arg1:string):Promise;
diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js
index c71ae77..ee3e2b1 100644
--- a/frontend/wailsjs/go/main/App.js
+++ b/frontend/wailsjs/go/main/App.js
@@ -5,3 +5,7 @@
export function Greet(arg1) {
return window['go']['main']['App']['Greet'](arg1);
}
+
+export function StartServer(arg1) {
+ return window['go']['main']['App']['StartServer'](arg1);
+}
diff --git a/frontend/wailsjs/go/main/Server.d.ts b/frontend/wailsjs/go/main/Server.d.ts
new file mode 100644
index 0000000..886a18e
--- /dev/null
+++ b/frontend/wailsjs/go/main/Server.d.ts
@@ -0,0 +1,4 @@
+// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
+// This file is automatically generated. DO NOT EDIT
+
+export function Start():Promise;
diff --git a/frontend/wailsjs/go/main/Server.js b/frontend/wailsjs/go/main/Server.js
new file mode 100644
index 0000000..66c97c3
--- /dev/null
+++ b/frontend/wailsjs/go/main/Server.js
@@ -0,0 +1,7 @@
+// @ts-check
+// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
+// This file is automatically generated. DO NOT EDIT
+
+export function Start() {
+ return window['go']['main']['Server']['Start']();
+}
diff --git a/go.mod b/go.mod
index 0ee1952..ce273e7 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,10 @@ go 1.21
toolchain go1.22.0
-require github.com/wailsapp/wails/v2 v2.8.0
+require (
+ github.com/estebangarcia21/subprocess v0.0.0-20230526204252-a1a6de4773be
+ github.com/wailsapp/wails/v2 v2.8.0
+)
require (
github.com/bep/debounce v1.2.1 // indirect
diff --git a/go.sum b/go.sum
index 6b41c31..767a8a0 100644
--- a/go.sum
+++ b/go.sum
@@ -3,6 +3,8 @@ github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3IS
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/estebangarcia21/subprocess v0.0.0-20230526204252-a1a6de4773be h1:Mf6Xc0DgENbsDgKn10KNCNmW9FYSTcMr2bFsJ9uzvX0=
+github.com/estebangarcia21/subprocess v0.0.0-20230526204252-a1a6de4773be/go.mod h1:PlHe6+WP6t7m4ghYrX6GBzB0KZLdOKWz2Ih3h0nusAY=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
diff --git a/main.go b/main.go
index 2b8109e..15e6a39 100644
--- a/main.go
+++ b/main.go
@@ -17,16 +17,22 @@ func main() {
// Create application with options
err := wails.Run(&options.App{
- Title: "server",
- Width: 1024,
- Height: 768,
+ Title: "server",
+ Width: 300,
+ Height: 600,
+ MinWidth: 200,
+ MinHeight: 400,
+ // Frameless: true,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.startup,
+ // CSSDragProperty: "--wails-draggable",
+ // CSSDragValue: "drag",
Bind: []interface{}{
app,
+ &Server{},
},
})