@@ -70,7 +70,10 @@ type workType struct {
70
70
71
71
// New constructs a new Workceptor instance.
72
72
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 ())
74
77
c , cancel := context .WithCancel (ctx )
75
78
w := & Workceptor {
76
79
ctx : c ,
@@ -96,27 +99,6 @@ func New(ctx context.Context, nc NetceptorForWorkceptor, dataDir string) (*Workc
96
99
// MainInstance is the global instance of Workceptor instantiated by the command-line main() function.
97
100
var MainInstance * Workceptor
98
101
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
-
120
102
// stdoutSize returns size of stdout, if it exists, or 0 otherwise.
121
103
func stdoutSize (unitdir string ) int64 {
122
104
stat , err := os .Stat (path .Join (unitdir , "stdout" ))
0 commit comments