Skip to content

Commit f8f2e78

Browse files
committed
Revert: Change default data directory ansible#902
1 parent f18e589 commit f8f2e78

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

pkg/workceptor/workceptor.go

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ type workType struct {
7070

7171
// New constructs a new Workceptor instance.
7272
func New(ctx context.Context, nc NetceptorForWorkceptor, dataDir string) (*Workceptor, error) {
73-
dataDir = setDataDir(dataDir, nc)
73+
if dataDir == "" {
74+
dataDir = path.Join(os.TempDir(), "receptor")
75+
}
76+
dataDir = path.Join(dataDir, nc.NodeID())
7477
c, cancel := context.WithCancel(ctx)
7578
w := &Workceptor{
7679
ctx: c,
@@ -96,27 +99,6 @@ func New(ctx context.Context, nc NetceptorForWorkceptor, dataDir string) (*Workc
9699
// MainInstance is the global instance of Workceptor instantiated by the command-line main() function.
97100
var MainInstance *Workceptor
98101

99-
// setDataDir returns a valid data directory.
100-
func setDataDir(dataDir string, nc NetceptorForWorkceptor) string {
101-
_, err := os.Stat(dataDir)
102-
if err == nil {
103-
return path.Join(dataDir, nc.NodeID())
104-
}
105-
nc.GetLogger().Warning("Receptor data directory provided does not exist \"%s\". Trying the default '/var/lib/receptor/", dataDir)
106-
107-
dataDir = "/var/lib/receptor"
108-
_, err = os.Stat(dataDir)
109-
if err == nil {
110-
return path.Join(dataDir, nc.NodeID())
111-
}
112-
nc.GetLogger().Warning("Receptor data directory \"%s\" does not exist. Setting tmp '/tmp/receptor/", dataDir)
113-
114-
dataDir = path.Join(os.TempDir(), "receptor")
115-
dataDir = path.Join(dataDir, nc.NodeID())
116-
117-
return dataDir
118-
}
119-
120102
// stdoutSize returns size of stdout, if it exists, or 0 otherwise.
121103
func stdoutSize(unitdir string) int64 {
122104
stat, err := os.Stat(path.Join(unitdir, "stdout"))

0 commit comments

Comments
 (0)