From 0e42613aefb2e7db8357e34a4172530b1c741f94 Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Fri, 4 Jun 2021 10:32:50 +0300 Subject: [PATCH] cmd: remove platform binary (#17712) --- Makefile | 1 - build/release.mk | 6 ---- cmd/mattermost/commands/root.go | 2 -- cmd/mattermost/commands/server.go | 10 ++----- cmd/mattermost/commands/server_test.go | 6 ++-- cmd/platform/main.go | 38 -------------------------- 6 files changed, 5 insertions(+), 58 deletions(-) delete mode 100644 cmd/platform/main.go diff --git a/Makefile b/Makefile index e0068765b2..962d15557d 100644 --- a/Makefile +++ b/Makefile @@ -576,7 +576,6 @@ clean: stop-docker ## Clean up everything except persistant server data. rm -f *.out rm -f *.test rm -f imports/imports.go - rm -f cmd/platform/cprofile*.out rm -f cmd/mattermost/cprofile*.out nuke: clean clean-docker ## Clean plus removes persistent server data. diff --git a/build/release.mk b/build/release.mk index 1530e75c66..afaf1ce49a 100644 --- a/build/release.mk +++ b/build/release.mk @@ -132,10 +132,8 @@ endif @# Copy binary ifeq ($(BUILDER_GOOS_GOARCH),"darwin_amd64") cp $(GOBIN)/mattermost $(DIST_PATH)/bin # from native bin dir, not cross-compiled - cp $(GOBIN)/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled else cp $(GOBIN)/darwin_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir - cp $(GOBIN)/darwin_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir endif #Download MMCTL for OSX scripts/download_mmctl_release.sh "Darwin" $(DIST_PATH)/bin @@ -167,10 +165,8 @@ endif @# Copy binary ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64") cp $(GOBIN)/mattermost.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled - cp $(GOBIN)/platform.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled else cp $(GOBIN)/windows_amd64/mattermost.exe $(DIST_PATH)/bin # from cross-compiled bin dir - cp $(GOBIN)/windows_amd64/platform.exe $(DIST_PATH)/bin # from cross-compiled bin dir endif #Download MMCTL for Windows scripts/download_mmctl_release.sh "Windows" $(DIST_PATH)/bin @@ -202,10 +198,8 @@ endif @# Copy binary ifeq ($(BUILDER_GOOS_GOARCH),"linux_amd64") cp $(GOBIN)/mattermost $(DIST_PATH)/bin # from native bin dir, not cross-compiled - cp $(GOBIN)/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled else cp $(GOBIN)/linux_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir - cp $(GOBIN)/linux_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir endif #Download MMCTL for Linux scripts/download_mmctl_release.sh "Linux" $(DIST_PATH)/bin diff --git a/cmd/mattermost/commands/root.go b/cmd/mattermost/commands/root.go index e2f83e3069..09b035d085 100644 --- a/cmd/mattermost/commands/root.go +++ b/cmd/mattermost/commands/root.go @@ -23,6 +23,4 @@ var RootCmd = &cobra.Command{ func init() { RootCmd.PersistentFlags().StringP("config", "c", "", "Configuration file to use.") RootCmd.PersistentFlags().Bool("disableconfigwatch", false, "When set config.json will not be loaded from disk when the file is changed.") - RootCmd.PersistentFlags().Bool("platform", false, "This flag signifies that the user tried to start the command from the platform binary, so we can log a mssage") - RootCmd.PersistentFlags().MarkHidden("platform") } diff --git a/cmd/mattermost/commands/server.go b/cmd/mattermost/commands/server.go index ce4e538783..011c5ce99e 100644 --- a/cmd/mattermost/commands/server.go +++ b/cmd/mattermost/commands/server.go @@ -39,8 +39,6 @@ func init() { func serverCmdF(command *cobra.Command, args []string) error { disableConfigWatch, _ := command.Flags().GetBool("disableconfigwatch") - usedPlatform, _ := command.Flags().GetBool("platform") - interruptChan := make(chan os.Signal, 1) if err := utils.TranslationsPreInit(); err != nil { @@ -58,10 +56,10 @@ func serverCmdF(command *cobra.Command, args []string) error { } defer configStore.Close() - return runServer(configStore, usedPlatform, interruptChan) + return runServer(configStore, interruptChan) } -func runServer(configStore *config.Store, usedPlatform bool, interruptChan chan os.Signal) error { +func runServer(configStore *config.Store, interruptChan chan os.Signal) error { // Setting the highest traceback level from the code. // This is done to print goroutines from all threads (see golang.org/issue/13161) // and also preserve a crash dump for later investigation. @@ -96,10 +94,6 @@ func runServer(configStore *config.Store, usedPlatform bool, interruptChan chan } }() - if usedPlatform { - mlog.Warn("The platform binary has been deprecated, please switch to using the mattermost binary.") - } - a := app.New(app.ServerConnector(server)) api := api4.Init(a, server.Router) diff --git a/cmd/mattermost/commands/server_test.go b/cmd/mattermost/commands/server_test.go index a31dee70f5..5345572fd4 100644 --- a/cmd/mattermost/commands/server_test.go +++ b/cmd/mattermost/commands/server_test.go @@ -66,7 +66,7 @@ func TestRunServerSuccess(t *testing.T) { // Use non-default listening port in case another server instance is already running. *configStore.Get().ServiceSettings.ListenAddress = UnitTestListeningPort - err := runServer(configStore, false, th.interruptChan) + err := runServer(configStore, th.interruptChan) require.NoError(t, err) } @@ -117,7 +117,7 @@ func TestRunServerSystemdNotification(t *testing.T) { *configStore.Get().ServiceSettings.ListenAddress = UnitTestListeningPort // Start and stop the server - err = runServer(configStore, false, th.interruptChan) + err = runServer(configStore, th.interruptChan) require.NoError(t, err) // Ensure the notification has been sent on the socket and is correct @@ -139,6 +139,6 @@ func TestRunServerNoSystemd(t *testing.T) { // Use non-default listening port in case another server instance is already running. *configStore.Get().ServiceSettings.ListenAddress = UnitTestListeningPort - err := runServer(configStore, false, th.interruptChan) + err := runServer(configStore, th.interruptChan) require.NoError(t, err) } diff --git a/cmd/platform/main.go b/cmd/platform/main.go deleted file mode 100644 index ce7ba328b2..0000000000 --- a/cmd/platform/main.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -package main - -import ( - "fmt" - "os" - "syscall" - - "github.com/mattermost/mattermost-server/v5/utils/fileutils" -) - -func main() { - // Print angry message to use mattermost command directly - fmt.Println(` ------------------------------------- ERROR ------------------------------------------------ -The platform binary has been deprecated, please switch to using the new mattermost binary. -The platform binary will be removed in a future version. -------------------------------------------------------------------------------------------- - `) - - // Execve the real MM binary - args := os.Args - args[0] = "mattermost" - args = append(args, "--platform") - - realMattermost := fileutils.FindFile("mattermost") - if realMattermost == "" { - realMattermost = fileutils.FindFile("bin/mattermost") - } - - if realMattermost == "" { - fmt.Println("Could not start Mattermost, use the mattermost command directly: failed to find mattermost") - } else if err := syscall.Exec(realMattermost, args, nil); err != nil { - fmt.Printf("Could not start Mattermost, use the mattermost command directly: %s\n", err.Error()) - } -}