1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +02:00

Move single-user-token to environment var

This commit is contained in:
Chen-I Lim 2021-02-11 10:13:17 -08:00
parent a7086325a6
commit 0082fd0dd3
5 changed files with 22 additions and 8 deletions

View File

@ -15,10 +15,12 @@ import (
var sessionToken string = "su-" + uuid.New().String()
func runServer(ctx context.Context) {
cmd := exec.CommandContext(ctx, "./focalboard-server", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user", sessionToken)
cmd := exec.CommandContext(ctx, "./focalboard-server", "--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()
if err != nil {
log.Println("Failed to start server")
log.Fatal(err)
}
log.Printf("Just ran subprocess %d, exiting\n", cmd.Process.Pid)

View File

@ -93,7 +93,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
NSLog("pid: \(pid)")
let serverProcess = Process()
serverProcess.currentDirectoryPath = cwdUrl.path
serverProcess.arguments = ["-monitorpid", "\(pid)", "-port", "\(serverPort)", "-single-user", sessionToken]
serverProcess.arguments = ["-monitorpid", "\(pid)", "-port", "\(serverPort)", "-single-user"]
serverProcess.environment = ["FOCALBOARD_SINGLE_USER_TOKEN": sessionToken]
serverProcess.launchPath = executablePath
serverProcess.launch()
self.serverProcess = serverProcess

View File

@ -63,12 +63,22 @@ func main() {
// Command line args
pMonitorPid := flag.Int("monitorpid", -1, "a process ID")
pPort := flag.Int("port", config.Port, "the port number")
pSingleUserToken := flag.String("single-user", "", "single user token")
pSingleUser := flag.Bool("single-user", false, "single user mode")
flag.Parse()
singleUser := false
if pSingleUser != nil {
singleUser = *pSingleUser
}
singleUserToken := ""
if pSingleUserToken != nil {
singleUserToken = *pSingleUserToken
if singleUser {
singleUserToken = os.Getenv("FOCALBOARD_SINGLE_USER_TOKEN")
if len(singleUserToken) < 1 {
log.Fatal("The FOCALBOARD_SINGLE_USER_TOKEN environment variable must be set for single user mode ")
return
}
log.Printf("Single user mode")
}
if pMonitorPid != nil && *pMonitorPid > 0 {

View File

@ -11,7 +11,7 @@
"check": "eslint --ext .tsx,.ts . --quiet --cache",
"fix": "eslint --ext .tsx,.ts . --quiet --fix --cache",
"i18n-extract": "formatjs extract src/**/*.tsx src/**/*.ts --out-file i18n/tmp.json; formatjs compile i18n/tmp.json --out-file i18n/en.json; rm i18n/tmp.json",
"runserver-test": "cd cypress && ../../bin/focalboard-server -single-user TESTTOKEN",
"runserver-test": "cd cypress && FOCALBOARD_SINGLE_USER_TOKEN=TESTTOKEN ../../bin/focalboard-server -single-user",
"cypress:ci": "start-server-and-test runserver-test http://localhost:8088 cypress:run",
"cypress:run": "cypress run",
"cypress:run:chrome": "cypress run --browser chrome",

View File

@ -16,12 +16,13 @@ import (
var sessionToken string = "su-" + uuid.New().String()
func runServer(ctx context.Context) *exec.Cmd {
// cmd := exec.CommandContext(ctx, "focalboard-server.exe", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user", sessionToken)
cmd := exec.CommandContext(ctx, "focalboard-server.exe", "-single-user", sessionToken)
// cmd := exec.CommandContext(ctx, "focalboard-server.exe", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user")
cmd := exec.CommandContext(ctx, "focalboard-server.exe", "-single-user")
// cmd := exec.CommandContext(ctx, "cmd.exe", "/C", "start", "./bin/focalboard-server.exe", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10))
// cmd := exec.CommandContext(ctx, "cmd.exe", "/C", "start", "./bin/focalboard-server.exe")
// cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
cmd.Env = []string{fmt.Sprintf("FOCALBOARD_SINGLE_USER_TOKEN=%s", sessionToken)}
cmd.Stdout = os.Stdout
go func() {
err := cmd.Run()