@@ -44,20 +44,20 @@ var (
44
44
45
45
// Defines local-specific node configuration. Supports setting default
46
46
// and node-specific values.
47
- type NodeProcess struct {
47
+ type ProcessRuntime struct {
48
48
node * Node
49
49
50
50
// PID of the node process
51
51
pid int
52
52
}
53
53
54
- func (p * NodeProcess ) setProcessContext (processContext node.ProcessContext ) {
54
+ func (p * ProcessRuntime ) setProcessContext (processContext node.ProcessContext ) {
55
55
p .pid = processContext .PID
56
56
p .node .URI = processContext .URI
57
57
p .node .StakingAddress = processContext .StakingAddress
58
58
}
59
59
60
- func (p * NodeProcess ) readState () error {
60
+ func (p * ProcessRuntime ) readState () error {
61
61
path := p .getProcessContextPath ()
62
62
bytes , err := os .ReadFile (path )
63
63
if errors .Is (err , fs .ErrNotExist ) {
@@ -80,7 +80,7 @@ func (p *NodeProcess) readState() error {
80
80
// its staking port. The network will start faster with this
81
81
// synchronization due to the avoidance of exponential backoff
82
82
// if a node tries to connect to a beacon that is not ready.
83
- func (p * NodeProcess ) Start (log logging.Logger ) error {
83
+ func (p * ProcessRuntime ) Start (log logging.Logger ) error {
84
84
// Avoid attempting to start an already running node.
85
85
proc , err := p .getProcess ()
86
86
if err != nil {
@@ -142,7 +142,7 @@ func (p *NodeProcess) Start(log logging.Logger) error {
142
142
}
143
143
144
144
// Signals the node process to stop.
145
- func (p * NodeProcess ) InitiateStop () error {
145
+ func (p * ProcessRuntime ) InitiateStop () error {
146
146
proc , err := p .getProcess ()
147
147
if err != nil {
148
148
return fmt .Errorf ("failed to retrieve process to stop: %w" , err )
@@ -158,7 +158,7 @@ func (p *NodeProcess) InitiateStop() error {
158
158
}
159
159
160
160
// Waits for the node process to stop.
161
- func (p * NodeProcess ) WaitForStopped (ctx context.Context ) error {
161
+ func (p * ProcessRuntime ) WaitForStopped (ctx context.Context ) error {
162
162
ticker := time .NewTicker (defaultNodeTickerInterval )
163
163
defer ticker .Stop ()
164
164
for {
@@ -178,7 +178,7 @@ func (p *NodeProcess) WaitForStopped(ctx context.Context) error {
178
178
}
179
179
}
180
180
181
- func (p * NodeProcess ) IsHealthy (ctx context.Context ) (bool , error ) {
181
+ func (p * ProcessRuntime ) IsHealthy (ctx context.Context ) (bool , error ) {
182
182
// Check that the node process is running as a precondition for
183
183
// checking health. getProcess will also ensure that the node's
184
184
// API URI is current.
@@ -197,11 +197,11 @@ func (p *NodeProcess) IsHealthy(ctx context.Context) (bool, error) {
197
197
return healthReply .Healthy , nil
198
198
}
199
199
200
- func (p * NodeProcess ) getProcessContextPath () string {
200
+ func (p * ProcessRuntime ) getProcessContextPath () string {
201
201
return filepath .Join (p .node .DataDir , config .DefaultProcessContextFilename )
202
202
}
203
203
204
- func (p * NodeProcess ) waitForProcessContext (ctx context.Context ) error {
204
+ func (p * ProcessRuntime ) waitForProcessContext (ctx context.Context ) error {
205
205
ticker := time .NewTicker (defaultNodeTickerInterval )
206
206
defer ticker .Stop ()
207
207
@@ -225,7 +225,7 @@ func (p *NodeProcess) waitForProcessContext(ctx context.Context) error {
225
225
// Retrieve the node process if it is running. As part of determining
226
226
// process liveness, the node's process context will be refreshed if
227
227
// live or cleared if not running.
228
- func (p * NodeProcess ) getProcess () (* os.Process , error ) {
228
+ func (p * ProcessRuntime ) getProcess () (* os.Process , error ) {
229
229
// Read the process context to ensure freshness. The node may have
230
230
// stopped or been restarted since last read.
231
231
if err := p .readState (); err != nil {
@@ -262,7 +262,7 @@ func getProcess(pid int) (*os.Process, error) {
262
262
}
263
263
264
264
// Write monitoring configuration enabling collection of metrics and logs from the node.
265
- func (p * NodeProcess ) writeMonitoringConfig () error {
265
+ func (p * ProcessRuntime ) writeMonitoringConfig () error {
266
266
// Ensure labeling that uniquely identifies the node and its network
267
267
commonLabels := FlagsMap {
268
268
// Explicitly setting an instance label avoids the default
@@ -300,7 +300,7 @@ func (p *NodeProcess) writeMonitoringConfig() error {
300
300
}
301
301
302
302
// Return the path for this node's prometheus configuration.
303
- func (p * NodeProcess ) getMonitoringConfigPath (name string ) (string , error ) {
303
+ func (p * ProcessRuntime ) getMonitoringConfigPath (name string ) (string , error ) {
304
304
// Ensure a unique filename to allow config files to be added and removed
305
305
// by multiple nodes without conflict.
306
306
serviceDiscoveryDir , err := getServiceDiscoveryDir (name )
@@ -311,7 +311,7 @@ func (p *NodeProcess) getMonitoringConfigPath(name string) (string, error) {
311
311
}
312
312
313
313
// Ensure the removal of the monitoring configuration files for this node.
314
- func (p * NodeProcess ) removeMonitoringConfig () error {
314
+ func (p * ProcessRuntime ) removeMonitoringConfig () error {
315
315
for _ , name := range []string {promtailCmd , prometheusCmd } {
316
316
configPath , err := p .getMonitoringConfigPath (name )
317
317
if err != nil {
@@ -325,7 +325,7 @@ func (p *NodeProcess) removeMonitoringConfig() error {
325
325
}
326
326
327
327
// Write the configuration for a type of monitoring (e.g. prometheus, promtail).
328
- func (p * NodeProcess ) writeMonitoringConfigFile (name string , config []FlagsMap ) error {
328
+ func (p * ProcessRuntime ) writeMonitoringConfigFile (name string , config []FlagsMap ) error {
329
329
configPath , err := p .getMonitoringConfigPath (name )
330
330
if err != nil {
331
331
return err
@@ -348,11 +348,11 @@ func (p *NodeProcess) writeMonitoringConfigFile(name string, config []FlagsMap)
348
348
return nil
349
349
}
350
350
351
- func (p * NodeProcess ) GetLocalURI (_ context.Context ) (string , func (), error ) {
351
+ func (p * ProcessRuntime ) GetLocalURI (_ context.Context ) (string , func (), error ) {
352
352
return p .node .URI , func () {}, nil
353
353
}
354
354
355
- func (p * NodeProcess ) GetLocalStakingAddress (_ context.Context ) (netip.AddrPort , func (), error ) {
355
+ func (p * ProcessRuntime ) GetLocalStakingAddress (_ context.Context ) (netip.AddrPort , func (), error ) {
356
356
return p .node .StakingAddress , func () {}, nil
357
357
}
358
358
0 commit comments