aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/sledjchisl
diff options
context:
space:
mode:
authoronefang2021-08-03 17:03:30 +1000
committeronefang2021-08-03 17:03:30 +1000
commit08ab8230e191ab4f6bd8a3a873ab8c7811155580 (patch)
treeaf3f052b3d5069fae7fccfcafadf509b86b02e29 /src/sledjchisl
parentTODO++ (diff)
downloadopensim-SC-08ab8230e191ab4f6bd8a3a873ab8c7811155580.zip
opensim-SC-08ab8230e191ab4f6bd8a3a873ab8c7811155580.tar.gz
opensim-SC-08ab8230e191ab4f6bd8a3a873ab8c7811155580.tar.bz2
opensim-SC-08ab8230e191ab4f6bd8a3a873ab8c7811155580.tar.xz
Close all the sim panes at full stop, and related cleanups.
Diffstat (limited to 'src/sledjchisl')
-rw-r--r--src/sledjchisl/sledjchisl.c101
1 files changed, 73 insertions, 28 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index 373dbb3..4c7d45f 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -7253,7 +7253,6 @@ jit library is loaded or the JIT compiler will not be activated.
7253// Other start up stuff. 7253// Other start up stuff.
7254//////////////////////////////////////////////////////////////////////////////////////////////////// 7254////////////////////////////////////////////////////////////////////////////////////////////////////
7255 getSims(); 7255 getSims();
7256
7257 if (isTmux || isWeb) 7256 if (isTmux || isWeb)
7258 { 7257 {
7259 char *d; 7258 char *d;
@@ -8015,18 +8014,6 @@ fcgiDone:
8015 ourSims->simsLua->unlock(ourSims->simsLua); 8014 ourSims->simsLua->unlock(ourSims->simsLua);
8016 } 8015 }
8017 8016
8018/*
8019sims = -- Note these are .shini / tmux tab short names.
8020{
8021 {['type'] = 'Welcome'; ['panes'] = 0; "Welcome"},
8022 {["type"] = "Important"; ["panes"] = 2; "Sandbox", "Shops"},
8023 {["type"] = "Rentals"; "Karen", "Bob"},
8024 {["type"] = "Freebies"; "Gifts", "Free"},
8025 {["type"] = "unsorted"; "New"}, -- NOTE - this is where new ones go to by default.
8026 {["type"] = "Water"; ["number"] = 20; ["panes"] = 6; "Water0", "Water1", "Water2", "Water3", "Water4"},
8027 {["type"] = "Heavies"; ["number"] = 18; "DP", "ARSE"},
8028}
8029*/
8030 8017
8031//////////////////////////////////////////////////////////////////////////////////////////////////// 8018////////////////////////////////////////////////////////////////////////////////////////////////////
8032// Sim wrangling loop. 8019// Sim wrangling loop.
@@ -8132,8 +8119,6 @@ sims = -- Note these are .shini / tmux tab short names.
8132 time_t curtime; 8119 time_t curtime;
8133 char date[DATE_TIME_LEN]; 8120 char date[DATE_TIME_LEN];
8134 8121
8135 cmd = xmprintf("%d.%d", simd->window, simd->pane);
8136
8137// TODO - should collect names of existing backups, both tmux / ini name and proper name. 8122// TODO - should collect names of existing backups, both tmux / ini name and proper name.
8138// Scan backups directory once before this for loop, add details to sims list. 8123// Scan backups directory once before this for loop, add details to sims list.
8139// strip off the last bit of file name (YYYY-mm-dd_HH:MM:SS.oar) to get the name 8124// strip off the last bit of file name (YYYY-mm-dd_HH:MM:SS.oar) to get the name
@@ -8143,7 +8128,7 @@ sims = -- Note these are .shini / tmux tab short names.
8143 strftime(date, DATE_TIME_LEN, "%F_%T", localtime(&curtime)); 8128 strftime(date, DATE_TIME_LEN, "%F_%T", localtime(&curtime));
8144 I("%s is being backed up to %s/backups/%s-%s.oar.", simd->name, scRoot, simd->tab, date); 8129 I("%s is being backed up to %s/backups/%s-%s.oar.", simd->name, scRoot, simd->tab, date);
8145 snprintf(toybuf, sizeof(toybuf), "save oar --all %s/backups/%s-%s.oar", scRoot, simd->tab, date); 8130 snprintf(toybuf, sizeof(toybuf), "save oar --all %s/backups/%s-%s.oar", scRoot, simd->tab, date);
8146 sendTmuxCmd(cmd, toybuf); 8131 sendTmuxCmd(simd->paneID, toybuf);
8147// if (0 == doWait) 8132// if (0 == doWait)
8148 { 8133 {
8149 memset(toybuf, 0, sizeof(toybuf)); 8134 memset(toybuf, 0, sizeof(toybuf));
@@ -8154,7 +8139,6 @@ sims = -- Note these are .shini / tmux tab short names.
8154// Have a config option for delete / gitAR. 8139// Have a config option for delete / gitAR.
8155 la = waitLoadAverage(la, loadAverageInc, simTimeOut); 8140 la = waitLoadAverage(la, loadAverageInc, simTimeOut);
8156 } 8141 }
8157 free(cmd);
8158 } 8142 }
8159 break; 8143 break;
8160 } 8144 }
@@ -8178,14 +8162,8 @@ sims = -- Note these are .shini / tmux tab short names.
8178 { 8162 {
8179 if (checkSimIsRunning(simd->tab)) 8163 if (checkSimIsRunning(simd->tab))
8180 { 8164 {
8181/* TODO - 8165 // Leave empty panes as is.
8182Leave empty panes as is. 8166 sendTmuxCmd(simd->paneID, "quit");
8183Don't bother to close panes unless we are doing a full stop.
8184Also clear out tmp when doing a full stop.
8185*/
8186 cmd = xmprintf("%d.%d", simd->window, simd->pane);
8187 sendTmuxCmd(cmd, "quit");
8188 free(cmd);
8189 // There's three things that might happen - 8167 // There's three things that might happen -
8190 // Sim will quit, tmux pane will go away before we can see the shutdown message. 8168 // Sim will quit, tmux pane will go away before we can see the shutdown message.
8191 // pane-exited hook might be useful here. 8169 // pane-exited hook might be useful here.
@@ -8193,7 +8171,7 @@ Also clear out tmp when doing a full stop.
8193 // pane-died hook might be useful here. 8171 // pane-died hook might be useful here.
8194 // Sim fails to quit, error message on the pane that we want to read, wont see the shutdown message. 8172 // Sim fails to quit, error message on the pane that we want to read, wont see the shutdown message.
8195 // Also sim might not have finished starting up, and may even not be accepting comands yet. 8173 // Also sim might not have finished starting up, and may even not be accepting comands yet.
8196 // TODO - cater for and test them all. 8174// TODO - cater for and test them all.
8197 // Could also loop on checkSimIsRunning(sim) 8175 // Could also loop on checkSimIsRunning(sim)
8198// snprintf(toybuf, sizeof(toybuf), "[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); 8176// snprintf(toybuf, sizeof(toybuf), "[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
8199// waitTmuxText(nm, toybuf); 8177// waitTmuxText(nm, toybuf);
@@ -8247,8 +8225,75 @@ Also clear out tmp when doing a full stop.
8247 } 8225 }
8248 else if ((STOP == currentMode) && (NULL == target)) 8226 else if ((STOP == currentMode) && (NULL == target))
8249 { 8227 {
8250I("Closing all the panes."); 8228 I("Closing all the panes.");
8251// TODO - Wait for all the sims to stop, close all the sim panes, even the empty ones. 8229 memset((void*)&obj0, 0, sizeof(obj0));
8230 ourSims->simsLua->lock(ourSims->simsLua);
8231 while(ourSims->simsLua->getnext(ourSims->simsLua, &obj0, false) == true)
8232 {
8233 q0 = obj0.data;
8234 char *type = "unsorted";
8235
8236 if (LUA_TTABLE == q0->type)
8237 {
8238 panes = 4;
8239 q1 = q0->v.t->get(q0->v.t, "number", NULL, false); if (NULL != q1) window = q1->v.f - 1;
8240 q1 = q0->v.t->get(q0->v.t, "panes", NULL, false); if (NULL != q1) panes = q1->v.f;
8241 q1 = q0->v.t->get(q0->v.t, "type", NULL, false); if (NULL != q1) type = q1->v.s;
8242 if (0 == panes)
8243 {
8244 pane = 2;
8245 window = 0;
8246 type = Ttab;
8247 }
8248 else if (0 != pane)
8249 {
8250 pane = 0;
8251 window++;
8252 }
8253
8254 memset((void*)&obj1, 0, sizeof(obj1));
8255 q0->v.t->lock(q0->v.t);
8256 while(q0->v.t->getnext(q0->v.t, &obj1, false) == true)
8257 {
8258 q1 = obj1.data;
8259
8260 if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0))
8261 {
8262 char *sim = q1->v.s;
8263 qlisttbl_t *ini = ourSims->byTab->get(ourSims->byTab, sim, NULL, false);
8264
8265 if (NULL == ini)
8266 E("Sim %s not found in ini list!", sim);
8267 else
8268 {
8269 simData *simd = ini->get(ini, "SIM DATA", NULL, false);
8270
8271 while (checkSimIsRunning(simd->tab))
8272 sleep(1);
8273 sleep(1);
8274 sendTmuxCmd(simd->paneID, "exit");
8275 I("Tmux tab [%d:%s](pane %d) tmux ID %s, from %s/sim%d - %s has stopped.", window, type, pane, simd->paneID, scTemp, count, simd->name);
8276
8277 count++;
8278 pane++;
8279 if (pane >= panes)
8280 {
8281 pane = 0;
8282 window++;
8283 }
8284 }
8285 }
8286 }
8287 q0->v.t->unlock(q0->v.t);
8288 }
8289 }
8290 ourSims->simsLua->unlock(ourSims->simsLua);
8291
8292 char *c = xmprintf("rm -fr %s/*", scTemp);
8293 if (!WIFEXITED(system(c)))
8294 E("rrm command failed! %s", c);
8295 free(c);
8296
8252 } 8297 }
8253//////////////////////////////////////////////////////////////////////////////////////////////////// 8298////////////////////////////////////////////////////////////////////////////////////////////////////
8254// End of OpenSim wrangling section. 8299// End of OpenSim wrangling section.