Worker: fix "failed to retrieve Orchard's home directory path" (#309)
When running through launchd and no HOME is set.
This commit is contained in:
parent
0a3d9c6d1c
commit
40f222c408
|
|
@ -1,10 +1,7 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"github.com/cirruslabs/orchard/internal/orchardhome"
|
||||
"github.com/spf13/cobra"
|
||||
"log"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var dataDirPath string
|
||||
|
|
@ -17,13 +14,8 @@ func NewCommand() *cobra.Command {
|
|||
|
||||
command.AddCommand(newRunCommand())
|
||||
|
||||
orchardHome, err := orchardhome.Path()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
command.PersistentFlags().StringVar(&dataDirPath, "data-dir", filepath.Join(orchardHome, "controller"),
|
||||
"path to the data controller's directory")
|
||||
command.PersistentFlags().StringVar(&dataDirPath, "data-dir", "",
|
||||
"path to the data controller's directory (defaults to $HOME/.orchard/controller)")
|
||||
|
||||
return command
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ import (
|
|||
configpkg "github.com/cirruslabs/orchard/internal/config"
|
||||
"github.com/cirruslabs/orchard/internal/controller"
|
||||
"github.com/cirruslabs/orchard/internal/netconstants"
|
||||
"github.com/cirruslabs/orchard/internal/orchardhome"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
|
|
@ -93,6 +95,15 @@ func runController(cmd *cobra.Command, args []string) (err error) {
|
|||
}
|
||||
|
||||
// Instantiate a data directory and ensure it's initialized
|
||||
if dataDirPath == "" {
|
||||
orchardHome, err := orchardhome.Path()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dataDirPath = filepath.Join(orchardHome, "controller")
|
||||
}
|
||||
|
||||
dataDir, err := controller.NewDataDir(dataDirPath)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -3,14 +3,9 @@
|
|||
package worker
|
||||
|
||||
import (
|
||||
"github.com/cirruslabs/orchard/internal/orchardhome"
|
||||
"github.com/spf13/cobra"
|
||||
"log"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var dataDirPath string
|
||||
|
||||
func NewCommand() *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: "worker",
|
||||
|
|
@ -19,13 +14,5 @@ func NewCommand() *cobra.Command {
|
|||
|
||||
command.AddCommand(newRunCommand())
|
||||
|
||||
orchardHome, err := orchardhome.Path()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
command.PersistentFlags().StringVar(&dataDirPath, "data-dir", filepath.Join(orchardHome, "worker"),
|
||||
"path to the worker's data directory")
|
||||
|
||||
return command
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue