github.com/qichengzx/mattermost-server@v4.5.1-0.20180604164826-2c75247c97d0+incompatible/cmd/platform/main.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package main
     5  
     6  import (
     7  	"fmt"
     8  	"os"
     9  	"path/filepath"
    10  	"syscall"
    11  )
    12  
    13  func findMattermostBinary() string {
    14  	for _, file := range []string{"./mattermost", "../mattermost", "./bin/mattermost"} {
    15  		path, _ := filepath.Abs(file)
    16  		if stat, err := os.Stat(path); err == nil && !stat.IsDir() {
    17  			return path
    18  		}
    19  	}
    20  	return "./mattermost"
    21  }
    22  
    23  func main() {
    24  	// Print angry message to use mattermost command directly
    25  	fmt.Println(`
    26  ------------------------------------ ERROR ------------------------------------------------
    27  The platform binary has been deprecated, please switch to using the new mattermost binary.
    28  The platform binary will be removed in a future version.
    29  -------------------------------------------------------------------------------------------
    30  	`)
    31  
    32  	// Execve the real MM binary
    33  	args := os.Args
    34  	args[0] = "mattermost"
    35  	args = append(args, "--platform")
    36  	if err := syscall.Exec(findMattermostBinary(), args, nil); err != nil {
    37  		fmt.Println("Could not start Mattermost, use the mattermost command directly.")
    38  	}
    39  }