TecplayTECPLAY

Server Manager (.ps1)

Gera um script PowerShell pra rodar teu servidor DayZ com watchdog (reinicia sozinho se cair), restart programado, log com horário e BEC — o que o start.bat faz mal. Roda 100% no navegador.

Pra rodar um .ps1: clique direito → Executar com PowerShell, ou no PowerShell powershell -ExecutionPolicy Bypass -File .\Start-DayZServer.ps1. Salve na pasta do servidor.

Servidor
Flags de log
Modo de execução

Intervalo do restart programado.

Tempo após parar antes de subir de novo.

BEC (scheduler / RCON)
Start-DayZServer.ps1
# Tecplay — Server Manager DayZ (PowerShell). Gerado em tecplay.inf.br/ferramentas
# Rode: clique direito > Executar com PowerShell (ou powershell -ExecutionPolicy Bypass -File este.ps1)

# ===== Configuracao (edite aqui) =====
$ServerName     = 'Meu Servidor DayZ'
$ServerLocation = 'C:\DayZServer'
$Exe            = 'DayZServer_x64.exe'
$Config         = 'serverDZ.cfg'
$Port           = 2302
$Profiles       = 'profiles'
$CpuCount       = 4
$Mods           = ''
$ServerMods     = ''
$RestartHours   = 4
$GraceSeconds   = 10
$LogFile        = Join-Path $ServerLocation 'server-manager.log'

# Log com horario
function Write-Log([string]$Message) {
    $line = "[{0}] {1}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $Message
    Write-Host $line
    Add-Content -Path $LogFile -Value $line
}

$ServerArgs = @(
    "-config=$Config",
    "-port=$Port",
    "-profiles=$Profiles",
    "-cpuCount=$CpuCount",
    "-mod=$Mods",
    "-serverMod=$ServerMods",
    '-dologs',
    '-adminlog',
    '-netlog',
    '-freezecheck'
)

function Start-DayZ {
    Write-Log "Subindo o servidor: $ServerName"
    $p = Start-Process -FilePath (Join-Path $ServerLocation $Exe) -WorkingDirectory $ServerLocation -ArgumentList ($ServerArgs -join ' ') -PassThru
    return $p
}

function Stop-DayZ {
    Get-Process -Name ([System.IO.Path]::GetFileNameWithoutExtension($Exe)) -ErrorAction SilentlyContinue | Stop-Process -Force
}

# ===== Loop principal =====
while ($true) {
    $proc = Start-DayZ
    $startedAt = Get-Date
    while (-not $proc.HasExited) {
        Start-Sleep -Seconds 15
        if (((Get-Date) - $startedAt).TotalHours -ge $RestartHours) {
            Write-Log ('Restart programado' + " ($RestartHours h)")
            Stop-DayZ
            break
        }
    }
    if ($proc.HasExited) { Write-Log 'Servidor caiu - reiniciando (watchdog)' }
    Stop-DayZ
    Write-Log ('Aguardando antes do proximo ciclo' + " ($GraceSeconds s)")
    Start-Sleep -Seconds $GraceSeconds
}

Achou útil? Encontrou bug?

Manda feedback que a Tecplay lê tudo e prioriza melhorias.