An attempt to divorce the start of the WS and UI

The intent is to be able to run on a remote system and tunnel
over ssh to the host and port so that it can start up and run
without the need for X or a GNU/KDE desktop

Change-Id: I6ad5843dc7c2963d379eaa4c3b842feacb016fff
This commit is contained in:
Schiefelbein, Andrew 2020-05-28 15:52:45 -05:00
parent f79fb476b1
commit 6ce2d4fcf7
2 changed files with 66 additions and 11 deletions

View File

@ -21,6 +21,25 @@ Run the airshipui binary
./bin/airshipui
# Running on a separate client & server
For development purposes it could be advantageous to split the webservice and the UI across 2 machines.
## To start the webservice on a remote system without starting the ui
bin/airshipui --headless
This will require you to tunnel the connection to the remote machine:
ssh -L 8080:localhost:8080 <id>@<remote_host>
## To start the UI to attach to a remote machine
bin/airshipui --remote
## Running the webservice on a remote machine with plugins
The plugins can run on the remote system but you will need to add additional SSH tunnels to the machine in order for it to work.
The plugins can also run locally but the remote server will still need the definition on the remote system to notify the UI that the plugins are available.
# Authentication
## Pluggable authentication methods
The AirshipUI is not designed to create authentication credentials but to have them supplied to it either by a configuration or by an external entity. The expectation is that there will be an external URL that will handle authentication for the system which may need to be modified or created. The endpoint will need to be able to forward a [bearer token](https://oauth.net/2/bearer-tokens/), [basic auth](https://en.wikipedia.org/wiki/Basic_access_authentication) or cookie data to the Airship UI backend service.

View File

@ -38,21 +38,19 @@ var rootCmd = &cobra.Command{
Version: Version(),
}
var headless bool
var remote bool
func init() {
// Add a 'version' command, in addition to the '--version' option that is auto created
rootCmd.AddCommand(newVersionCmd())
// add the remote & headless options in case people want to run a split setup
rootCmd.Flags().BoolVar(&headless, "headless", false, "start the system in headless webserver only, no ui.")
rootCmd.Flags().BoolVar(&remote, "remote", false, "start the system in remote ui only, no webserver.")
}
func launch(cmd *cobra.Command, args []string) {
// only process args if there are any
// TODO: what flags do we care about and what shall we do with them?
if cmd.Flags().NFlag() > 0 {
log.Printf("Executing AirshipUI with the following args: %v\n", args)
}
// start the webservice
go webservice.WebServer()
sigs := make(chan os.Signal)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
@ -86,18 +84,56 @@ func launch(cmd *cobra.Command, args []string) {
)
}
// start the electron app
err := electron.RunElectron()
// just a little ditty to see if we should open the ui or the webservice or both
switch handleStartType() {
case "headless":
// start webservice and listen for the the ctl + c to exit
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
log.Println("Exiting the webservice")
os.Exit(0)
}()
webservice.WebServer()
case "remote":
// start the electron app
startElectron()
default:
// start webservice and electron
go webservice.WebServer()
startElectron()
}
// cancel running plugins and wait for shut down
cancel()
waitgrp.Wait()
}
func startElectron() {
err := electron.RunElectron()
if err != nil {
log.Printf("Exit %s", err)
}
}
// TODO: determine if cobra can make flags exclusive without the extra logic
func handleStartType() string {
st := "default"
if remote && headless {
log.Fatalf("Cannot set both --remote and --headless flags")
}
if remote {
st = "remote"
} else if headless {
st = "headless"
}
return st
}
// Execute is called from the main program and kicks this whole shindig off
func Execute() {
if err := rootCmd.Execute(); err != nil {
log.Println(err)