Merge branch 'master' into client-data-loading

This commit is contained in:
AffectedArc07
2021-08-29 20:56:41 +01:00
committed by GitHub
152 changed files with 7816 additions and 9426 deletions
+5
View File
@@ -11,6 +11,11 @@ SUBSYSTEM_DEF(acid)
/datum/controller/subsystem/acid/stat_entry()
..("P:[processing.len]")
/datum/controller/subsystem/acid/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/acid/fire(resumed = 0)
if(!resumed)
+6
View File
@@ -66,6 +66,12 @@ SUBSYSTEM_DEF(air)
msg += "AT/MS:[round((cost ? active_turfs.len/cost : 0),0.1)]"
..(msg)
/datum/controller/subsystem/air/get_metrics()
. = ..()
var/list/cust = list()
cust["active_turfs"] = length(active_turfs)
cust["hotspots"] = length(hotspots)
.["custom"] = cust
/datum/controller/subsystem/air/Initialize(timeofday)
setup_overlays() // Assign icons and such for gas-turf-overlays
+6
View File
@@ -12,6 +12,12 @@ SUBSYSTEM_DEF(fires)
..("P:[processing.len]")
/datum/controller/subsystem/fires/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/fires/fire(resumed = 0)
if(!resumed)
src.currentrun = processing.Copy()
+16
View File
@@ -61,6 +61,22 @@ SUBSYSTEM_DEF(garbage)
msg += " | Fail:[fail_counts.Join(",")]"
..(msg)
/datum/controller/subsystem/garbage/get_metrics()
. = ..()
var/list/cust = list()
if((delslasttick + gcedlasttick) == 0) // Account for DIV0
cust["gcr"] = 0
else
cust["gcr"] = (gcedlasttick / (delslasttick + gcedlasttick))
cust["total_harddels"] = totaldels
cust["total_softdels"] = totalgcs
var/i = 0
for(var/list/L in queues)
i++
cust["queue_[i]"] = length(L)
.["custom"] = cust
/datum/controller/subsystem/garbage/Shutdown()
//Adds the del() log to the qdel log file
var/list/dellog = list()
+8
View File
@@ -11,6 +11,14 @@ SUBSYSTEM_DEF(lighting)
/datum/controller/subsystem/lighting/stat_entry()
..("L:[length(sources_queue)]|C:[length(corners_queue)]|O:[length(objects_queue)]")
/datum/controller/subsystem/lighting/get_metrics()
. = ..()
var/list/cust = list()
cust["sources_queue"] = length(sources_queue)
cust["corners_queue"] = length(corners_queue)
cust["objects_queue"] = length(objects_queue)
.["custom"] = cust
/datum/controller/subsystem/lighting/Initialize(timeofday)
if(!initialized)
if(GLOB.configuration.general.starlight)
+6
View File
@@ -20,6 +20,12 @@ SUBSYSTEM_DEF(machines)
fire()
return ..()
/datum/controller/subsystem/machines/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/machines/proc/makepowernets()
for(var/datum/powernet/PN in powernets)
qdel(PN)
+1 -1
View File
@@ -62,7 +62,7 @@ SUBSYSTEM_DEF(mapping)
log_startup_progress("Populating lavaland...")
var/lavaland_setup_timer = start_watch()
seedRuins(list(level_name_to_num(MINING)), GLOB.configuration.ruins.lavaland_ruin_budget, /area/lavaland/surface/outdoors/unexplored, GLOB.lava_ruins_templates)
spawn_rivers(list(level_name_to_num(MINING)))
spawn_rivers(level_name_to_num(MINING))
log_startup_progress("Successfully populated lavaland in [stop_watch(lavaland_setup_timer)]s.")
// Now we make a list of areas for teleport locs
+47
View File
@@ -0,0 +1,47 @@
SUBSYSTEM_DEF(metrics)
name = "Metrics"
wait = 30 SECONDS
offline_implications = "Server metrics will no longer be ingested into monitoring systems. No immediate action is needed."
runlevels = RUNLEVEL_LOBBY | RUNLEVEL_SETUP | RUNLEVEL_GAME | RUNLEVEL_POSTGAME // ALL THE LEVELS
flags = SS_KEEP_TIMING // This needs to ingest every 30 IRL seconds, not ingame seconds.
/// The real time of day the server started. Used to calculate time drift
var/world_init_time = 0 // Not set in here. Set in world/New()
/datum/controller/subsystem/metrics/Initialize(start_timeofday)
if(!GLOB.configuration.metrics.enable_metrics)
flags |= SS_NO_FIRE // Disable firing to save CPU
return ..()
/datum/controller/subsystem/metrics/fire(resumed)
SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, GLOB.configuration.metrics.metrics_endpoint, get_metrics_json(), list(
"Authorization" = "ApiKey [GLOB.configuration.metrics.metrics_api_token]",
"Content-Type" = "application/json"
))
/datum/controller/subsystem/metrics/proc/get_metrics_json()
var/list/out = list()
out["@timestamp"] = time_stamp() // This is required by ElasticSearch, complete with this name. DO NOT REMOVE THIS.
out["cpu"] = world.cpu
// out["maptick"] = world.map_cpu // TODO: 514
out["elapsed_processed"] = world.time
out["elapsed_real"] = (REALTIMEOFDAY - world_init_time)
out["client_count"] = length(GLOB.clients)
out["round_id"] = text2num(GLOB.round_id) // This is so we can filter the metrics by a single round ID
// Funnel in all SS metrics
var/list/ss_data = list()
for(var/datum/controller/subsystem/SS in Master.subsystems)
ss_data[SS.ss_id] = SS.get_metrics()
out["subsystems"] = ss_data
// And send it all
return json_encode(out)
/*
// Uncomment this if you add new metrics to verify how the JSON formats
/client/verb/debugmetricts()
usr << browse(SSmetrics.get_metrics_json(), "window=aadebug")
*/
+6
View File
@@ -12,6 +12,12 @@ SUBSYSTEM_DEF(mobs)
/// The amount of giant spiders that exist in the world. Used for mob capping.
var/giant_spiders = 0
/datum/controller/subsystem/mobs/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(GLOB.mob_living_list)
.["custom"] = cust
/datum/controller/subsystem/mobs/stat_entry()
..("P:[GLOB.mob_living_list.len]")
@@ -14,6 +14,12 @@ SUBSYSTEM_DEF(processing)
/datum/controller/subsystem/processing/stat_entry()
..("[stat_tag]:[processing.len]")
/datum/controller/subsystem/processing/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/processing/fire(resumed = 0)
if(!resumed)
currentrun = processing.Copy()
+31 -1
View File
@@ -1,9 +1,16 @@
PROCESSING_SUBSYSTEM_DEF(radiation)
name = "Radiation"
flags = SS_NO_INIT | SS_BACKGROUND
flags = SS_BACKGROUND | SS_NO_INIT
wait = 1 SECONDS
offline_implications = "Radiation will no longer function; power generation may not happen. A restart may or may not be required, depending on the situation."
var/list/warned_atoms = list()
// Cache radiation levels for each turf so it doesn't need to be done iteratively
// turf_rad_cache is the state in the current loop, and may not be 100% representative
// until processing is complete.
// prev_rad_cache is the fully evaluated radiation state cache from the previous tick.
var/list/turf_rad_cache = list()
var/list/prev_rad_cache = list()
/datum/controller/subsystem/processing/radiation/proc/warn(datum/component/radioactive/contamination)
if(!contamination || QDELETED(contamination))
@@ -16,3 +23,26 @@ PROCESSING_SUBSYSTEM_DEF(radiation)
SSblackbox.record_feedback("tally", "contaminated", 1, master.type)
var/msg = "has become contaminated with enough radiation to contaminate other objects. || Source: [contamination.source] || Strength: [contamination.strength]"
master.investigate_log(msg, "radiation")
/datum/controller/subsystem/processing/radiation/fire(resumed)
refresh_rad_cache()
. = ..()
/datum/controller/subsystem/processing/radiation/proc/get_turf_radiation(turf/place)
if (prev_rad_cache[place])
return prev_rad_cache[place]
else
return 0
/datum/controller/subsystem/processing/radiation/proc/update_rad_cache(datum/component/radioactive/thing)
var/atom/owner = thing.parent
var/turf/place = get_turf(owner)
if (turf_rad_cache[place])
turf_rad_cache[place] += thing.strength
else
turf_rad_cache[place] = thing.strength
/datum/controller/subsystem/processing/radiation/proc/refresh_rad_cache()
prev_rad_cache = turf_rad_cache.Copy()
turf_rad_cache = list()
@@ -0,0 +1,45 @@
#define QUEUE_DATA_FILE "data/queue_data.json"
// These are defines for the sake of making sure we get the right keys
#define QUEUE_DATA_FILE_THRESHOLD_KEY "threshold"
#define QUEUE_DATA_FILE_ENABLED_KEY "enabled"
#define QUEUE_DATA_FILE_PERSISTENT_KEY "persistent"
SUBSYSTEM_DEF(queue)
name = "Server Queue"
init_order = INIT_ORDER_QUEUE // 100
flags = SS_NO_FIRE
/// Threshold of players to queue new people
var/queue_threshold = 0
/// Whether the queue is enabled or not
var/queue_enabled = FALSE
/// Whether to persist these settings over multiple rounds
var/persist_queue = FALSE
/// List of ckeys allowed to bypass queue this round
var/list/queue_bypass_list = list()
/// Last world.time we let a ckey in. 3 second delay between each letin to avoid a mass bubble
var/last_letin_time = 0
/datum/controller/subsystem/queue/Initialize(start_timeofday)
if(fexists(QUEUE_DATA_FILE))
try
var/F = file2text(QUEUE_DATA_FILE)
var/list/data = json_decode(F)
queue_threshold = data[QUEUE_DATA_FILE_THRESHOLD_KEY]
queue_enabled = data[QUEUE_DATA_FILE_ENABLED_KEY]
persist_queue = data[QUEUE_DATA_FILE_PERSISTENT_KEY]
catch
stack_trace("Failed to load [QUEUE_DATA_FILE] from disk due to malformed JSON. You may need to setup the queue again.")
return ..()
/datum/controller/subsystem/queue/Shutdown()
// Save if persistent
if(persist_queue)
if(fexists(QUEUE_DATA_FILE))
fdel(QUEUE_DATA_FILE)
var/data = list()
data[QUEUE_DATA_FILE_THRESHOLD_KEY] = queue_threshold
data[QUEUE_DATA_FILE_ENABLED_KEY] = queue_enabled
data[QUEUE_DATA_FILE_PERSISTENT_KEY] = persist_queue
var/json_data = json_encode(data)
text2file(json_data, QUEUE_DATA_FILE)
+5
View File
@@ -12,6 +12,11 @@ SUBSYSTEM_DEF(spacedrift)
/datum/controller/subsystem/spacedrift/stat_entry()
..("P:[processing.len]")
/datum/controller/subsystem/spacedrift/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/spacedrift/fire(resumed = 0)
if(!resumed)
+8 -1
View File
@@ -27,6 +27,13 @@ SUBSYSTEM_DEF(tgui)
/datum/controller/subsystem/tgui/stat_entry()
..("P:[processing_uis.len]")
/datum/controller/subsystem/tgui/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing_uis)
.["custom"] = cust
/datum/controller/subsystem/tgui/fire(resumed = 0)
if (!resumed)
src.currentrun = processing_uis.Copy()
@@ -119,7 +126,7 @@ SUBSYSTEM_DEF(tgui)
* Close all UIs attached to src_object.
* Returns the number of UIs closed.
*
* * datum/src_objectThe object/datum which owns the UIs.
* * datum/src_object - The object/datum which owns the UIs.
*/
/datum/controller/subsystem/tgui/proc/close_uis(datum/src_object)
if(!src_object.unique_datum_id) // First check if the datum has an UID set
+6
View File
@@ -15,6 +15,12 @@ SUBSYSTEM_DEF(throwing)
/datum/controller/subsystem/throwing/stat_entry()
..("P:[processing.len]")
/datum/controller/subsystem/throwing/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/throwing/fire(resumed = 0)
if(!resumed)
src.currentrun = processing.Copy()
@@ -3,6 +3,7 @@ GLOBAL_REAL(SSmentor_tickets, /datum/controller/subsystem/tickets/mentor_tickets
/datum/controller/subsystem/tickets/mentor_tickets/New()
NEW_SS_GLOBAL(SSmentor_tickets)
PreInit()
ss_id = "mentor_tickets"
/datum/controller/subsystem/tickets/mentor_tickets
name = "Mentor Tickets"
@@ -41,6 +41,12 @@ SUBSYSTEM_DEF(tickets)
var/ticketCounter = 1
/datum/controller/subsystem/tickets/get_metrics()
. = ..()
var/list/cust = list()
cust["tickets"] = length(allTickets) // Not a perf metric but I want to see a graph where SSair usage spikes and 20 tickets come in
.["custom"] = cust
/datum/controller/subsystem/tickets/Initialize()
if(!close_messages)
close_messages = list("<font color='red' size='4'><b>- [ticket_name] Rejected! -</b></font>",
+6
View File
@@ -37,6 +37,12 @@ SUBSYSTEM_DEF(timer)
/datum/controller/subsystem/timer/stat_entry(msg)
..("B:[bucket_count] P:[length(second_queue)] H:[length(hashes)] C:[length(clienttime_timers)] S:[length(timer_id_dict)]")
/datum/controller/subsystem/timer/get_metrics()
. = ..()
var/list/cust = list()
cust["bucket_count"] = bucket_count
.["custom"] = cust
/datum/controller/subsystem/timer/fire(resumed = FALSE)
var/lit = last_invoke_tick
var/last_check = world.time - TICKS2DS(BUCKET_LEN*1.5)
+7 -1
View File
@@ -9,11 +9,17 @@ SUBSYSTEM_DEF(weather)
flags = SS_BACKGROUND
wait = 10
runlevels = RUNLEVEL_GAME
offline_implications = "Ash storms will no longer trigger. No immediate action is needed."
offline_implications = "Ash storms will no longer trigger. No immediate action is needed."
var/list/processing = list()
var/list/eligible_zlevels = list()
var/list/next_hit_by_zlevel = list() //Used by barometers to know when the next storm is coming
/datum/controller/subsystem/weather/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/weather/fire()
// process active weather
for(var/V in processing)