<?php
require_once("guiconfig.inc");

const DDNSGO_PID_FILE = '/var/run/ddnsgo.pid';

// 检查服务是否运行
function isServiceRunning(): bool {
    $pid = @file_get_contents(DDNSGO_PID_FILE);
    return $pid && is_numeric($pid) && posix_kill((int) $pid, 0);
}

// 返回状态
header('Content-Type: application/json');
echo json_encode(['status' => isServiceRunning() ? 'running' : 'stopped']);