File size: 1,765 Bytes
65b3647
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$ErrorActionPreference = "Continue"
$root = Resolve-Path (Join-Path $PSScriptRoot "..")
$open = Join-Path $root "vendor\open-mt2"
$data = Join-Path $root "runtime\mariadb-data"

function Port-Listen([int]$port) {
  return [bool](netstat -an | Select-String ":$port\s+.*LISTENING")
}

# Redis
if (-not (Port-Listen 6379)) {
  $redis = "C:\Program Files\Redis\redis-server.exe"
  if (Test-Path $redis) { Start-Process $redis -WindowStyle Minimized; Start-Sleep 2 }
}

# MariaDB
if (-not (Port-Listen 3306)) {
  $mysqld = "C:\Program Files\MariaDB 12.3\bin\mysqld.exe"
  if (Test-Path $mysqld) {
    New-Item -ItemType Directory -Force -Path (Join-Path $root "runtime") | Out-Null
    Start-Process $mysqld -ArgumentList @(
      "--datadir=$data","--port=3306","--bind-address=127.0.0.1",
      "--innodb-buffer-pool-size=128M","--console"
    ) -WindowStyle Hidden
    Start-Sleep 6
  }
}

# Auth
if (-not (Port-Listen 11002)) {
  Start-Process cmd.exe -ArgumentList "/c","cd /d `"$open`" && npx cross-env LOG_LEVEL=info tsnd -r tsconfig-paths/register --transpile-only --env-file=.env src/auth/main.ts" -WindowStyle Minimized
  Start-Sleep 4
}

# Game
if (-not (Port-Listen 13001)) {
  Start-Process cmd.exe -ArgumentList "/c","cd /d `"$open`" && npx cross-env LOG_LEVEL=info tsnd -r tsconfig-paths/register --transpile-only --env-file=.env src/game/main.ts" -WindowStyle Minimized
  Start-Sleep 6
}

Write-Host "Ports:"
foreach ($p in 6379,3306,11002,13001) {
  Write-Host ("  {0}: {1}" -f $p, $(if (Port-Listen $p) {"UP"} else {"DOWN"}))
}
Write-Host "Auth/Game: 127.0.0.1:11002 / 13001  |  login admin/admin"
Write-Host "Client: copy client_config\serverinfo.py into TMP4 client"
Write-Host "Gold: python scripts\set_player_gold.py --name CHAR --gold 999999999"