okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
b0282b1
main
1- module ( albedo_active_output_probe ). 2- export ([ stats / 1 , expire / 2 , sweep / 1 ]). 3 4stats ( Id ) -> 5{ some , Subject } = 'albedo@daemon@session' : live ( Id ), 6{ ok , Owner } = 'gleam@erlang@process' : subject_owner ( Subject ), 7erlang : garbage_collect ( Owner ), 8Info = process_info ( Owner , [ memory , binary , reductions , message_queue_len ]), 9Binaries = maps : from_list ([{ Ref , Size } || { Ref , Size , _ } <- proplists : get_value ( binary , Info )]), 10json : encode ( # { actor_heap_bytes =>proplists : get_value ( memory , Info ), 11actor_binary_bytes =>lists : sum ( maps : values ( Binaries )), 12actor_reductions =>proplists : get_value ( reductions , Info ), 13mailbox =>proplists : get_value ( message_queue_len , Info )}). 14 15expire ( Home , Id ) -> 16Path = filename : join ([ Home , << "active-output" >>, << Id / binary , ".meta" >>]), 17{ ok , Binary } = file : read_file ( Path ), 18Meta = binary_to_term ( Binary ), 19ok = file : write_file ( Path , term_to_binary ( Meta # { expires =>0 })), 20<< "true" >>. 21 22sweep ( Home ) -> 23albedo_active_output : maintenance ( Home ), 24<< "true" >>.