Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Param -systemd_system=false to use systemd --user
Browse files Browse the repository at this point in the history
  • Loading branch information
hmalphettes committed Nov 23, 2015
1 parent 0d116e7 commit b3b76da
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
DisableEngine bool
VerifyUnits bool
UnitsDirectory string
SystemdSystem bool
AuthorizedKeysFile string
}

Expand Down
2 changes: 2 additions & 0 deletions fleetd/fleetd.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func main() {
cfgset.String("metadata", "", "List of key-value metadata to assign to the fleet machine")
cfgset.String("agent_ttl", agent.DefaultTTL, "TTL in seconds of fleet machine state in etcd")
cfgset.String("units_directory", "/run/fleet/units/", "Path to the fleet units directory")
cfgset.Bool("systemd_system", true, "When false use systemd --user)")
cfgset.Int("token_limit", 100, "Maximum number of entries per page returned from API requests")
cfgset.Bool("disable_engine", false, "Disable the engine entirely, use with care")
cfgset.Bool("verify_units", false, "DEPRECATED - This option is ignored")
Expand Down Expand Up @@ -198,6 +199,7 @@ func getConfig(flagset *flag.FlagSet, userCfgFile string) (*config.Config, error
DisableEngine: (*flagset.Lookup("disable_engine")).Value.(flag.Getter).Get().(bool),
VerifyUnits: (*flagset.Lookup("verify_units")).Value.(flag.Getter).Get().(bool),
UnitsDirectory: (*flagset.Lookup("units_directory")).Value.(flag.Getter).Get().(string),
SystemdSystem: (*flagset.Lookup("systemd_system")).Value.(flag.Getter).Get().(bool),
TokenLimit: (*flagset.Lookup("token_limit")).Value.(flag.Getter).Get().(int),
AuthorizedKeysFile: (*flagset.Lookup("authorized_keys_file")).Value.(flag.Getter).Get().(string),
}
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func New(cfg config.Config) (*Server, error) {
return nil, err
}

mgr, err := systemd.NewSystemdUnitManager(cfg.UnitsDirectory)
mgr, err := systemd.NewSystemdUnitManager(cfg.UnitsDirectory, cfg.SystemdSystem)
if err != nil {
return nil, err
}
Expand Down
11 changes: 9 additions & 2 deletions systemd/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type systemdUnitManager struct {
mutex sync.RWMutex
}

func NewSystemdUnitManager(uDir string) (*systemdUnitManager, error) {
systemd, err := dbus.New()
func NewSystemdUnitManager(uDir string, systemBus bool) (*systemdUnitManager, error) {
systemd, err := createDbusConnection(systemBus)
if err != nil {
return nil, err
}
Expand All @@ -60,6 +60,13 @@ func NewSystemdUnitManager(uDir string) (*systemdUnitManager, error) {
return &mgr, nil
}

func createDbusConnection(systemdSystem bool) (*dbus.Conn, error) {
if systemdSystem {
return dbus.New()
}
return dbus.NewUserConnection()
}

func hashUnitFiles(dir string) (map[string]unit.Hash, error) {
uNames, err := lsUnitsDir(dir)
if err != nil {
Expand Down

0 comments on commit b3b76da

Please sign in to comment.