-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some small cleanup changes pulled out of the quiet logger PR #838
Changes from all commits
e4379d2
f70cc2a
7990bcf
3dfc2c9
7517c9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,10 @@ interface EventBase<T extends PackageReference = ScriptReference> { | |
// Success events | ||
// ------------------------------- | ||
|
||
type Success = ExitZero | NoCommand | Fresh | Cached; | ||
/** | ||
* A script finished successfully. | ||
*/ | ||
export type Success = ExitZero | NoCommand | Fresh | Cached; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, when exporting should add a jsdoc comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
|
||
interface SuccessBase<T extends PackageReference = ScriptReference> | ||
extends EventBase<T> { | ||
|
@@ -70,6 +73,9 @@ export interface Cached extends SuccessBase { | |
// Failure events | ||
// ------------------------------- | ||
|
||
/** | ||
* A problem was encountered. | ||
*/ | ||
export type Failure = | ||
| ExitNonZero | ||
| ExitSignal | ||
|
@@ -313,7 +319,10 @@ export interface UnknownErrorThrown extends ErrorBase { | |
// Output events | ||
// ------------------------------- | ||
|
||
type Output = Stdout | Stderr; | ||
/** | ||
* A script emitted output. | ||
*/ | ||
export type Output = Stdout | Stderr; | ||
|
||
interface OutputBase extends EventBase<ScriptConfig> { | ||
type: 'output'; | ||
|
@@ -338,15 +347,21 @@ export interface Stderr extends OutputBase { | |
// Informational events | ||
// ------------------------------- | ||
|
||
type Info = | ||
/** | ||
* Something happened, neither success nor failure, though often progress. | ||
*/ | ||
export type Info = | ||
| ScriptRunning | ||
| ScriptLocked | ||
| OutputModified | ||
| WatchRunStart | ||
| WatchRunEnd | ||
| ServiceStarted | ||
| ServiceProcessStarted | ||
| ServiceReady | ||
| ServiceStopped | ||
| GenericInfo; | ||
| AnalysisStarted | ||
| AnalysisCompleted | ||
| CacheInfo; | ||
|
||
interface InfoBase<T extends PackageReference = ScriptReference> | ||
extends EventBase<T> { | ||
|
@@ -377,6 +392,24 @@ export interface OutputModified extends InfoBase { | |
detail: 'output-modified'; | ||
} | ||
|
||
/** | ||
* The analysis phase for a run has begun, where we load package.json | ||
* files, analyze their wireit configs, and build the dependency graph. | ||
*/ | ||
export interface AnalysisStarted extends InfoBase { | ||
detail: 'analysis-started'; | ||
} | ||
|
||
/** | ||
* The analysis phase for a run has completed. If successful, we have a | ||
* rootScriptConfig with a full dependency graph. If unsuccessful, it is | ||
* undefined, and there will be a Failure event with more information. | ||
*/ | ||
export interface AnalysisCompleted extends InfoBase { | ||
detail: 'analysis-completed'; | ||
rootScriptConfig: undefined | ScriptConfig; | ||
} | ||
|
||
/** | ||
* A watch mode iteration started. | ||
*/ | ||
|
@@ -392,10 +425,18 @@ export interface WatchRunEnd extends InfoBase { | |
} | ||
|
||
/** | ||
* A service started running. | ||
* A service process started running. | ||
*/ | ||
export interface ServiceProcessStarted extends InfoBase { | ||
detail: 'service-process-started'; | ||
} | ||
|
||
/** | ||
* A service started running and if it has a readyWhen condition, | ||
* that condition is met. | ||
*/ | ||
export interface ServiceStarted extends InfoBase { | ||
detail: 'service-started'; | ||
export interface ServiceReady extends InfoBase { | ||
detail: 'service-ready'; | ||
} | ||
|
||
/** | ||
|
@@ -406,9 +447,9 @@ export interface ServiceStopped extends InfoBase { | |
} | ||
|
||
/** | ||
* A generic info event. | ||
* An advisory event about caching. | ||
*/ | ||
export interface GenericInfo extends InfoBase { | ||
detail: 'generic'; | ||
export interface CacheInfo extends InfoBase { | ||
detail: 'cache-info'; | ||
message: string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,15 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand<ServiceScri | |
entireExecutionAborted, | ||
adoptee, | ||
}; | ||
// Doing this here ensures that we always log when the | ||
// service stops, no matter how that happens. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there other conditions outside the I do like hanging this off the promise. edit: is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before this change we'd only log that it stopped if we stopped it outselves and it was in certain specific states. This way, no matter how it dies (e.g. it chooses to call process.exit()), we inform the logger about it. |
||
void this._terminated.promise.then(() => { | ||
this._logger.log({ | ||
script: this._config, | ||
type: 'info', | ||
detail: 'service-stopped', | ||
}); | ||
}); | ||
} | ||
|
||
/** | ||
|
@@ -818,6 +827,11 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand<ServiceScri | |
private _onChildStarted() { | ||
switch (this._state.id) { | ||
case 'starting': { | ||
this._logger.log({ | ||
script: this._config, | ||
type: 'info', | ||
detail: 'service-process-started', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Is it worth reflecting the state names in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Starting makes sense to the internal state machine of ServiceScriptExecution, but for everywhere else at this point we have a child process now, so the process has started. |
||
}); | ||
if (this._state.readyMonitor !== undefined) { | ||
this._state = { | ||
id: 'readying', | ||
|
@@ -838,7 +852,7 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand<ServiceScri | |
this._logger.log({ | ||
script: this._config, | ||
type: 'info', | ||
detail: 'service-started', | ||
detail: 'service-ready', | ||
}); | ||
this._state = { | ||
id: 'started', | ||
|
@@ -879,7 +893,7 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand<ServiceScri | |
this._logger.log({ | ||
script: this._config, | ||
type: 'info', | ||
detail: 'service-started', | ||
detail: 'service-ready', | ||
}); | ||
this._state = { | ||
id: 'started', | ||
|
@@ -914,11 +928,6 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand<ServiceScri | |
switch (this._state.id) { | ||
case 'stopping': { | ||
this._enterStoppedState(); | ||
this._logger.log({ | ||
script: this._config, | ||
type: 'info', | ||
detail: 'service-stopped', | ||
}); | ||
return; | ||
} | ||
case 'readying': { | ||
|
@@ -944,11 +953,6 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand<ServiceScri | |
return; | ||
} | ||
case 'failing': { | ||
this._logger.log({ | ||
script: this._config, | ||
type: 'info', | ||
detail: 'service-stopped', | ||
}); | ||
this._enterFailedState(this._state.failure); | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this impact Windows users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Often
/
works everywhere but\
only works on Windows. If it does then we could likely remove this by then