Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
tweak: ensure framework stops on more errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanctech committed Jan 24, 2021
1 parent 0974811 commit d6165af
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sonorancad/core/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function getApiUrl()
if ApiUrls[Config.mode] ~= nil then
return ApiUrls[Config.mode]
else
Config.critError = true
assert(false, "Invalid mode. Valid values are production, development")
end
end
Expand All @@ -26,13 +27,14 @@ CreateThread(function()
ApiVersion = tonumber(string.sub(result, 1, 1))
if ApiVersion < 2 then
errorLog("ERROR: Your community cannot use any plugins requiring the API. Please purchase a subscription of Standard or higher.")
assert(false)
Config.critError = true
end
debugLog(("Set version %s from response %s"):format(ApiVersion, result))
infoLog(("Loaded community ID %s with API URL: %s"):format(Config.communityID, Config.apiUrl))
end)
if Config.primaryIdentifier == "steam" and GetConvar("steam_webapiKey", "none") == "none" then
errorLog("You have set SonoranCAD to Steam mode, but have not configured a Steam Web API key. Please see FXServer documentation. SonoranCAD will not function in Steam mode without this set.")
Config.critError = true
end
end)

Expand Down Expand Up @@ -108,7 +110,7 @@ function performApiRequest(postData, type, cb)
debugLog(("type %s called with post data %s to url %s"):format(type, json.encode(payload), url))
if statusCode == 200 and res ~= nil then
debugLog("result: "..tostring(res))
if res == "Sonoran CAD: Backend Service Reached" then
if res == "Sonoran CAD: Backend Service Reached" or res == "Backend Service Reached" then
errorLog(("API ERROR: Invalid endpoint (URL: %s). Ensure you're using a valid endpoint."):format(url))
else
cb(res, true)
Expand Down Expand Up @@ -161,7 +163,6 @@ CreateThread(function()
serverId = Config.serverId,
plugins = plugins
}
debugLog(("Heartbeat: %s"):format(json.encode(payload)))
performApiRequest(payload, "HEARTBEAT", function() end)
Wait(1000*60*60)
end
Expand Down

0 comments on commit d6165af

Please sign in to comment.