Improving linux client

This commit is contained in:
Jesús Espino 2021-04-23 10:38:24 +02:00
parent f5ae0b265a
commit 6b7589f67a
6 changed files with 1530 additions and 25 deletions

View file

@ -153,12 +153,11 @@ win-wpf-app: server-dll webapp
cd win-wpf && ./build.bat && ./package.bat
cd win-wpf && ./package-zip.bat
linux-app: server-linux webapp
linux-app: webapp
rm -rf linux/temp
rm -rf linux/dist
mkdir -p linux/dist
mkdir -p linux/temp/focalboard-app
cp bin/linux/focalboard-server linux/temp/focalboard-app/
cp app-config.json linux/temp/focalboard-app/config.json
cp build/MIT-COMPILED-LICENSE.md linux/temp/focalboard-app/
cp NOTICE.txt linux/temp/focalboard-app/

View file

@ -4,5 +4,6 @@ go 1.15
require (
github.com/google/uuid v1.2.0
github.com/mattermost/focalboard/server v0.0.0-20210422230105-f5ae0b265a8d
github.com/webview/webview v0.0.0-20200724072439-e0c01595b361
)

File diff suppressed because it is too large Load diff

View file

@ -1,46 +1,81 @@
package main
import (
"context"
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"strconv"
"net"
"github.com/google/uuid"
"github.com/mattermost/focalboard/server/server"
"github.com/mattermost/focalboard/server/services/config"
"github.com/webview/webview"
)
var sessionToken string = "su-" + uuid.New().String()
func runServer(ctx context.Context) {
executable, err := os.Executable()
func getFreePort() (int, error) {
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
if err != nil {
log.Println("Failed to get os.Executable()")
log.Fatal(err)
return 0, err
}
serverExecutable := filepath.Join(filepath.Dir(executable), "focalboard-server")
cmd := exec.CommandContext(ctx, serverExecutable, "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user")
cmd.Env = []string{fmt.Sprintf("FOCALBOARD_SINGLE_USER_TOKEN=%s", sessionToken)}
cmd.Stdout = os.Stdout
err = cmd.Run()
l, err := net.ListenTCP("tcp", addr)
if err != nil {
log.Println("Failed to start server")
log.Fatal(err)
return 0, err
}
log.Printf("Just ran subprocess %d, exiting\n", cmd.Process.Pid)
defer l.Close()
return l.Addr().(*net.TCPAddr).Port, nil
}
func runServer(port int) (*server.Server, error) {
server, err := server.New(&config.Configuration{
ServerRoot: fmt.Sprintf("http://localhost:%d", port),
Port: port,
DBType: "sqlite3",
DBConfigString: "./focalboard.db",
UseSSL: false,
SecureCookie: true,
WebPath: "./pack",
FilesPath: "./focalboard_files",
Telemetry: true,
WebhookUpdate: []string{},
Secret: "",
SessionExpireTime: 259200000000,
SessionRefreshTime: 18000,
LocalOnly: false,
EnableLocalMode: false,
LocalModeSocketLocation: "",
AuthMode: "native",
MattermostURL: "",
MattermostClientID: "",
MattermostClientSecret: "",
}, sessionToken)
if err != nil {
fmt.Println("ERROR INITIALIZING THE SERVER", err)
return nil, err
}
err = server.Start()
if err != nil {
return nil, err
}
return server, nil
}
func main() {
debug := true
w := webview.New(debug)
defer w.Destroy()
ctx, cancel := context.WithCancel(context.Background())
go runServer(ctx)
port, err := getFreePort()
if err != nil {
log.Println("Failed to open a free port")
log.Fatal(err)
}
server, err := runServer(port)
if err != nil {
log.Println("Failed to start the server")
log.Fatal(err)
}
w.SetTitle("Focalboard")
w.SetSize(1024, 768, webview.HintNone)
@ -48,7 +83,7 @@ func main() {
script := fmt.Sprintf("localStorage.setItem('focalboardSessionId', '%s');", sessionToken)
w.Init(script)
w.Navigate("http://localhost:8088")
w.Navigate(fmt.Sprintf("http://localhost:%d", port))
w.Run()
cancel()
server.Shutdown()
}

View file

@ -1 +0,0 @@
../bin/octoserver

1
linux/pack Symbolic link
View file

@ -0,0 +1 @@
../webapp/pack