Skip to content

Commit

Permalink
Merge pull request #1251 from gettakaro/main-promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele authored Sep 7, 2024
2 parents f7e253b + 6a15ac4 commit 9c8c54f
Show file tree
Hide file tree
Showing 22 changed files with 220 additions and 53 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy docs to Pages

on:
push:
branches: ["main"]
branches: ['main']

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
Expand All @@ -12,7 +12,7 @@ permissions:

# Allow one concurrent deployment
concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: true

jobs:
Expand All @@ -36,7 +36,7 @@ jobs:

- run: ./scripts/dev-init.sh

- run: npm -w packages/web-docs run export
- run: npm -w packages/web-docs run build

- name: Generate API client docs
run: |
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: "./packages/web-docs/build"
path: './packages/web-docs/build'

- name: Deploy to GitHub Pages
id: deployment
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dev-to-main-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ on:
push:
branches:
- development
- main
jobs:
mainPromotion:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/development'
steps:
- name: Generate token
id: generate_token
Expand Down Expand Up @@ -39,6 +41,7 @@ jobs:
updateDevelopment:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Generate token
id: generate_token
Expand Down
118 changes: 85 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/app-api/src/controllers/GameServerController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
IsBoolean,
IsEnum,
IsISO8601,
IsJSON,
Expand Down Expand Up @@ -86,6 +87,14 @@ class GameServerSearchInputAllowedFilters {
@IsOptional()
@IsEnum(GAME_SERVER_TYPE, { each: true })
type!: GAME_SERVER_TYPE[];

@IsOptional()
@IsBoolean({ each: true })
reachable!: boolean[];

@IsOptional()
@IsBoolean({ each: true })
enabled!: boolean[];
}

class GameServerSearchInputDTO extends ITakaroQuery<GameServerOutputDTO> {
Expand Down
8 changes: 8 additions & 0 deletions packages/app-api/src/service/GameServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export class GameServerOutputDTO extends TakaroModelDTO<GameServerOutputDTO> {
type: GAME_SERVER_TYPE;
@IsBoolean()
reachable: boolean;
@IsBoolean()
enabled: boolean;
}

export class GameServerCreateDTO extends TakaroDTO<GameServerCreateDTO> {
Expand All @@ -106,6 +108,9 @@ export class GameServerUpdateDTO extends TakaroDTO<GameServerUpdateDTO> {
@IsBoolean()
@IsOptional()
reachable: boolean;
@IsBoolean()
@IsOptional()
enabled: boolean;
}

export class ModuleInstallDTO extends TakaroDTO<ModuleInstallDTO> {
Expand Down Expand Up @@ -362,6 +367,9 @@ export class GameServerService extends TakaroService<

async getGame(id: string): Promise<IGameServer> {
const gameserver = await this.repo.findOne(id, true);

if (!gameserver.enabled) throw new errors.BadRequestError('Game server is disabled');

let gameInstance = gameClassCache.get(id);

if (gameInstance) {
Expand Down
2 changes: 1 addition & 1 deletion packages/app-api/src/workers/playerSyncWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function processJob(job: Job<IGameServerQueueData>) {
const promises = [];

const gameserverService = new GameServerService(domain.id);
const gameServers = await gameserverService.find({});
const gameServers = await gameserverService.find({ filters: { enabled: [true] } });
promises.push(
...gameServers.results.map(async (gs) => {
const reachable = await gameserverService.testReachability(gs.id);
Expand Down
14 changes: 11 additions & 3 deletions packages/app-connector/src/lib/GameServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,18 @@ class GameServerManager {
*/
private async syncServers() {
const isFirstTimeRun = this.emitterMap.size === 0;
const domains = await takaro.domain.domainControllerSearch();
const enabledDomains = domains.data.data.filter((domain) => domain.state === DomainOutputDTOStateEnum.Active);
const enabledDomains = (
await takaro.domain.domainControllerSearch({ filters: { state: [DomainOutputDTOStateEnum.Active] } })
).data.data;

const gameServers: Map<string, GameServerOutputDTO[]> = new Map();

const results = await Promise.allSettled(
enabledDomains.map(async (domain) => {
const client = await getDomainClient(domain.id);
const gameServersRes = await client.gameserver.gameServerControllerSearch();
const gameServersRes = await client.gameserver.gameServerControllerSearch({
filters: { enabled: [true], reachable: [true] },
});
gameServers.set(domain.id, gameServersRes.data.data);
}),
);
Expand Down Expand Up @@ -140,6 +143,11 @@ class GameServerManager {
return;
}

if (!gameServer.enabled) {
this.log.warn(`GameServer ${gameServerId} is not enabled, skipping...`);
return;
}

if (this.emitterMap.has(gameServer.id)) {
this.log.warn(`GameServer ${gameServerId} already connected, stopping the existing one...`);
await this.remove(gameServer.id);
Expand Down
4 changes: 2 additions & 2 deletions packages/lib-apiclient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "npm run test:unit --if-present && npm run test:integration --if-present",
"test:unit": "echo 'No tests (yet :))'",
"test:integration": "mocha --config ../../.mocharc.js src/**/*.integration.test.ts --exit",
"generate": "npx @openapitools/openapi-generator-cli generate -i ${TAKARO_HOST}/openapi.json -g typescript-axios -o ./src/generated/",
"generate": "node ../../scripts/wait-until-healthy.mjs && npx @openapitools/openapi-generator-cli generate -i ${TAKARO_HOST}/openapi.json -g typescript-axios -o ./src/generated/",
"postgenerate": "./fix-esm.sh && npm run build"
},
"keywords": [],
Expand All @@ -21,4 +21,4 @@
"devDependencies": {
"@openapitools/openapi-generator-cli": "^2.5.2"
}
}
}
Loading

0 comments on commit 9c8c54f

Please sign in to comment.