Update to goprogram 0.1.0
This commit is contained in:
parent
d2d681a4f2
commit
7cda92b342
31 changed files with 141 additions and 244 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
|
||||
|
|
@ -8,7 +11,8 @@ import (
|
|||
|
||||
// Params are used to initialize the excutable.
|
||||
type Params struct {
|
||||
ConfigPath string // ConfigPath is the path to the configuration file for the distillery
|
||||
ConfigPath string // ConfigPath is the path to the configuration file for the distillery
|
||||
Context context.Context // Context for the distillery
|
||||
}
|
||||
|
||||
// ParamsFromEnv creates a new set of parameters from the environment.
|
||||
|
|
@ -28,5 +32,19 @@ func ParamsFromEnv() (params Params, err error) {
|
|||
|
||||
// and add the configuration file name to it!
|
||||
params.ConfigPath = filepath.Join(params.ConfigPath, ConfigFile)
|
||||
|
||||
// generate a new context
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
params.Context = ctx
|
||||
|
||||
// cancel the context on an interrupt
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func() {
|
||||
<-c
|
||||
cancel()
|
||||
}()
|
||||
|
||||
// and return the params!
|
||||
return params, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue