Skip to content
Newer
Older
100644 66 lines (53 sloc) 1.69 KB
b478a13 @Abstrct Bug in move fixed. Tic.pl now run in a screen session rather than a c…
authored
1 #!/usr/bin/perl
2 #############################
84d9b25 create_scheamverse.sql is dead, long live create_schemaverse.sql. The…
Abstract authored
3 # Ref v0.1 #
b478a13 @Abstrct Bug in move fixed. Tic.pl now run in a screen session rather than a c…
authored
4 # Created by Josh McDougall #
5 #############################
6 # This should be run inside a screen session
7 # Ref.pl makes sure no player has a query over ~1 minute.
8 # Logging could be added here to monitor players trying to cuase problems and disable their accounts
9
10
11 # use module
12 use DBI;
13
14 # Config Variables
15 my $db_name = "schemaverse";
16 my $db_username = "schemaverse";
17
18 while (1){
19
20 # Make the master database connection
21 my $master_connection = DBI->connect("dbi:Pg:dbname=${db_name};host=localhost", $db_username);
22
23
24 my $sql = <<SQLSTATEMENT;
25 select
84d9b25 create_scheamverse.sql is dead, long live create_schemaverse.sql. The…
Abstract authored
26 pid as pid,
27 pg_notify(get_player_error_channel(usename::character varying), 'The following query was canceled due to timeout: ' ||query ),
20b666c @Abstrct Changes all over these here parts. This is the edition of the game th…
authored
28 disable_fleet(CASE WHEN application_name ~ '^[0-9]+\$' THEN application_name::integer ELSE 0 END) as disabled,
b478a13 @Abstrct Bug in move fixed. Tic.pl now run in a screen session rather than a c…
authored
29 usename as username,
84d9b25 create_scheamverse.sql is dead, long live create_schemaverse.sql. The…
Abstract authored
30 query as current_query,
31 pg_cancel_backend(pid) as canceled
b478a13 @Abstrct Bug in move fixed. Tic.pl now run in a screen session rather than a c…
authored
32 from
33 pg_stat_activity
34 where
87eaf3f @Abstrct Fleets are now free but if you want them to run you need to upgrade t…
authored
35 datname = '${db_name}'
36 AND usename <> '${db_username}'
20b666c @Abstrct Changes all over these here parts. This is the edition of the game th…
authored
37 AND usename <> 'postgres'
87eaf3f @Abstrct Fleets are now free but if you want them to run you need to upgrade t…
authored
38 AND
39 (
40 (
84d9b25 create_scheamverse.sql is dead, long live create_schemaverse.sql. The…
Abstract authored
41 query LIKE '%FLEET_SCRIPT_%'
87eaf3f @Abstrct Fleets are now free but if you want them to run you need to upgrade t…
authored
42 AND (now() - query_start) > COALESCE(
20b666c @Abstrct Changes all over these here parts. This is the edition of the game th…
authored
43 GET_FLEET_RUNTIME(CASE WHEN application_name ~ '^[0-9]+\$' THEN application_name::integer ELSE 0 END, usename::character varying),
84d9b25 create_scheamverse.sql is dead, long live create_schemaverse.sql. The…
Abstract authored
44 '60 seconds'::interval)
87eaf3f @Abstrct Fleets are now free but if you want them to run you need to upgrade t…
authored
45 )
46 OR
47 (
84d9b25 create_scheamverse.sql is dead, long live create_schemaverse.sql. The…
Abstract authored
48 query NOT LIKE '<IDLE>%'
49 AND query NOT LIKE '%FLEET_SCRIPT_%'
50 AND now() - query_start > interval '60 seconds'
87eaf3f @Abstrct Fleets are now free but if you want them to run you need to upgrade t…
authored
51 )
52 )
b478a13 @Abstrct Bug in move fixed. Tic.pl now run in a screen session rather than a c…
authored
53 SQLSTATEMENT
54
55 my $rs = $master_connection->prepare($sql);
56 $rs->execute();
87eaf3f @Abstrct Fleets are now free but if you want them to run you need to upgrade t…
authored
57
58 #while (($pid, $error_channel, $username, $current_query, $canceled) = $rs->fetchrow()) {}
59
b478a13 @Abstrct Bug in move fixed. Tic.pl now run in a screen session rather than a c…
authored
60 $rs->finish;
61
62 $master_connection->disconnect();
63 sleep(30);
64
65 }
Something went wrong with that request. Please try again.