Fix multiple server instances overwriting profiles with old data (!291)
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/291 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
ffbeefba6f
commit
521cf51f0e
@ -17,6 +17,7 @@ import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
export class HttpServer
|
||||
{
|
||||
protected httpConfig: IHttpConfig;
|
||||
protected started: boolean;
|
||||
|
||||
constructor(
|
||||
@inject("WinstonLogger") protected logger: ILogger,
|
||||
@ -37,6 +38,8 @@ export class HttpServer
|
||||
*/
|
||||
public load(): void
|
||||
{
|
||||
this.started = false;
|
||||
|
||||
/* create server */
|
||||
const httpServer: Server = http.createServer();
|
||||
|
||||
@ -48,6 +51,7 @@ export class HttpServer
|
||||
/* Config server to listen on a port */
|
||||
httpServer.listen(this.httpConfig.port, this.httpConfig.ip, () =>
|
||||
{
|
||||
this.started = true;
|
||||
this.logger.success(
|
||||
this.localisationService.getText("started_webserver_success", this.httpServerHelper.getBackendUrl()),
|
||||
);
|
||||
@ -123,4 +127,9 @@ export class HttpServer
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public isStarted(): boolean
|
||||
{
|
||||
return this.started;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { ICoreConfig } from "@spt-aki/models/spt/config/ICoreConfig";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||
import { HttpServer } from "@spt-aki/servers/HttpServer";
|
||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
import { EncodingUtil } from "@spt-aki/utils/EncodingUtil";
|
||||
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
||||
@ -23,6 +24,7 @@ export class App
|
||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||
@inject("EncodingUtil") protected encodingUtil: EncodingUtil,
|
||||
@inject("HttpServer") protected httpServer: HttpServer,
|
||||
@injectAll("OnLoad") protected onLoadComponents: OnLoad[],
|
||||
@injectAll("OnUpdate") protected onUpdateComponents: OnUpdate[],
|
||||
)
|
||||
@ -64,6 +66,12 @@ export class App
|
||||
|
||||
protected async update(onUpdateComponents: OnUpdate[]): Promise<void>
|
||||
{
|
||||
// If the server has failed to start, skip any update calls
|
||||
if (!this.httpServer.isStarted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (const updateable of onUpdateComponents)
|
||||
{
|
||||
let success = false;
|
||||
|
Loading…
Reference in New Issue
Block a user