github.com/nilium/gitlab-runner@v12.5.0+incompatible/commands/user_mode_warning.go (about)

     1  package commands
     2  
     3  import (
     4  	"os"
     5  	"runtime"
     6  
     7  	"github.com/sirupsen/logrus"
     8  )
     9  
    10  func userModeWarning(withRun bool) {
    11  	logrus.WithFields(logrus.Fields{
    12  		"GOOS": runtime.GOOS,
    13  		"uid":  os.Getuid(),
    14  	}).Debugln("Checking runtime mode")
    15  
    16  	// everything is supported on windows
    17  	if runtime.GOOS == "windows" {
    18  		return
    19  	}
    20  
    21  	systemMode := os.Getuid() == 0
    22  
    23  	// We support services on Linux, Windows and Darwin
    24  	noServices :=
    25  		runtime.GOOS != "linux" &&
    26  			runtime.GOOS != "darwin"
    27  
    28  	// We don't support services installed as an User on Linux
    29  	noUserService :=
    30  		!systemMode &&
    31  			runtime.GOOS == "linux"
    32  
    33  	if systemMode {
    34  		logrus.Infoln("Running in system-mode.")
    35  	} else {
    36  		logrus.Warningln("Running in user-mode.")
    37  	}
    38  
    39  	if withRun {
    40  		if noServices {
    41  			logrus.Warningln("You need to manually start builds processing:")
    42  			logrus.Warningln("$ gitlab-runner run")
    43  		} else if noUserService {
    44  			logrus.Warningln("The user-mode requires you to manually start builds processing:")
    45  			logrus.Warningln("$ gitlab-runner run")
    46  		}
    47  	}
    48  
    49  	if !systemMode {
    50  		logrus.Warningln("Use sudo for system-mode:")
    51  		logrus.Warningln("$ sudo gitlab-runner...")
    52  	}
    53  	logrus.Infoln("")
    54  }