Date: 2017/03/01 08:42:45 UTC-08:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
managedUpdateStatement:
- ^inject locally requisiteDataCheck instantly
- ^inject locally loadFile instantly
- ^define status '<yaml[SQLManager_Offline].read[Offline_Cache.databases.%db%.status]||null>'
- ^if <def[status].is[==].to[offline]> || <def[status].is[==].to[connecting]> {
- announce "<&b>SQLManager<&co> <&c>Entry added to <&b>%db%<&c> offline queue!" to_console
- yaml set Offline_Cache.databases.%db%.statements.%timestamp%:->:<def[statement]> 'id:SQLManager_Offline'
- yaml 'savefile:SQLManager/cache.yml' 'id:SQLManager_Offline'
}
else {
- if <proc[SQLManager_ConnectionCheck].context[%db%]> {
- sql id:%db% "update:<def[statement]>" save:id
- define id <entry[id].result.get[1].split[/].get[1]||null>
}
else {
- yaml set 'id:SQLManager_Offline' 'Offline_Cache.databases.%db%.status:offline'
- yaml set Offline_Cache.databases.%db%.statements.%timestamp%:->:<def[statement]> 'id:SQLManager_Offline'
- yaml 'savefile:SQLManager/cache.yml' 'id:SQLManager_Offline'
- announce "<&b>SQLManager<&co> <&c>Managed Connection Check failed for <&b>%db%<&c>!" to_console
- announce "<&b>SQLManager<&co> <&c>Entry added to <&b>%db%<&c> offline queue!" to_console
- run s@SQLManager p:restart def:%yamlName%|%scriptName%|%db%
- wait 5s
}
}
processOfflineQueue:
- ^announce "<&b>SQLManager<&co> <&3>Processing Offline Queue for <&b>%db%<&3>..." to_console
- define index '<yaml[SQLManager_Offline].list_keys[Offline_Cache.databases.%db%.statements].numerical||li@>'
- ^if <def[index].is_empty||true> {
- if <proc[SQLManager_ConnectionCheck].context[%db%]> {
- yaml set 'id:SQLManager_Offline' 'Offline_Cache.databases.%db%.status:online'
- yaml 'savefile:SQLManager/cache.yml' 'id:SQLManager_Offline'
- announce "<&b>SQLManager<&co> <&d>%db% Now Online!" to_console
- inject locally reloadfile instantly
}
else {
- yaml set 'id:SQLManager_Offline' 'Offline_Cache.databases.%db%.status:offline'
- announce "<&b>SQLManager<&co> <&c>Encountered an error while processing Offline queue for <&b>%db%<&c>!" to_console
- announce "<&b>SQLManager<&co> <&c>Reverting <&b>%db%<&c> to offline mode..." to_console
- run s@SQLManager p:restart def:%yamlName%|%scriptName%|%db%
}
}
else {
- foreach %index% {
- define statement '<yaml[SQLManager_Offline].read[Offline_Cache.databases.%db%.statements.%value%].after[@]||null>'
- if <proc[SQLManager_ConnectionCheck].context[%db%]> {
- sql id:%db% "update:<def[statement]>"
- yaml set Offline_Cache.databases.%db%.statements:<-:%value% 'id:SQLManager_Offline'
- yaml 'savefile:SQLManager/cache.yml' 'id:SQLManager_Offline'
- wait 1t
}
else {
- yaml set 'id:SQLManager_Offline' 'Offline_Cache.databases.%db%.status:offline'
- announce "<&b>SQLManager<&co> <&c>Encountered an error while processing Offline queue for <&b>%db%<&c>!" to_console
- announce "<&b>SQLManager<&co> <&c>Reverting <&b>%db%<&c> to offline mode" to_console
- run s@SQLManager p:restart def:%yamlName%|%scriptName%|%db%
- foreach stop
}
}
- if <proc[SQLManager_ConnectionCheck].context[%db%]> {
- inject locally processOfflineQueue
}
else {
- yaml set 'id:SQLManager_Offline' 'Offline_Cache.databases.%db%.status:offline'
- announce "<&b>SQLManager<&co> <&c>Encountered an error while processing Offline queue for <&b>%db%<&c>!" to_console
- announce "<&b>SQLManager<&co> <&c>Reverting <&b>%db%<&c> to offline mode" to_console
- run s@SQLManager p:restart def:%yamlName%|%scriptName%|%db%
}
}