From ac47760e89efe58857338eac3c4a8ae1fd45eeca Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 30 Jul 2021 04:55:09 +1000 Subject: More rejigging of painful tmux panes. Almost there. --- src/sledjchisl/sledjchisl.c | 78 +++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 978bf33..8aad370 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -722,6 +722,7 @@ struct _simData // portH is the HTTP port for the sim, portU is the UDP port for the sim. int locX, locY, sizeX, sizeY, sizeZ, portH, portU, maxPrims; char *name, *tab, *UUID, *regionType, *estate, *owner; + char *paneID; int window, pane; }; @@ -7668,10 +7669,6 @@ fcgiDone: { // Join the session. doTmuxCmd("select-window -t '%s' \\; attach-session -t '%s'", Tconsole, Tconsole); -// snprintf(toybuf, sizeof(toybuf), "%s %s/%s select-window -t '%s' \\; attach-session -t '%s'", Tcmd, scRun, Tsocket, Tconsole, Tconsole); -// i = system(toybuf); -// if (!WIFEXITED(i)) -// E("tmux attach-session command failed! %s", toybuf); goto finished; } @@ -7692,7 +7689,7 @@ sims = -- Note these are .shini / tmux tab short names. { int count = 0, window = 0, panes = 4, pane = 0; - I("Loading configuration file - %s", toybuf); + I("Loading sims file - %s", toybuf); status = luaL_loadfile(L, toybuf); if (status) // If something went wrong, error message is at the top of the stack. E("Couldn't load file: %s", lua_tostring(L, -1)); @@ -7789,6 +7786,7 @@ sims = -- Note these are .shini / tmux tab short names. { char *path = xmprintf("%s/%s.shini", scEtc, nm); char *newPath = xmprintf("%s/sim%d/%s.ini", scTemp, count, nm); // Coz OpenSim. + char *cmd; if (0 == panes) doTmuxCmd("split-window -hp 50 -d -t '%s:0.1'", Tconsole); @@ -7810,39 +7808,41 @@ sims = -- Note these are .shini / tmux tab short names. doTmuxCmd("split-window -hp 50 -d -t '%s:%d.0'", Tconsole, window); } /* TODO - -tmux -S /opt/opensim_SC-DG/var/run/opensim-tmux.socket list-panes -t 31 -F '#{pane_index} #{pane_id}' -0 %39 -1 %42 -2 %40 -3 %41 +IDs={ +['21 0'] = '@17.%65', +['21 1'] = '@17.%68', +['21 2'] = '@17.%66', +['21 3'] = '@17.%67', +} +return IDs -I can get the tabs to show their ID. session:window.pane $sessionID $=ExactSessionMatch @windowID @=ExactWindowMatch %paneID - "The pane ID is passed to the child process of the pane in the TMUX_PANE environment variable." - Tuck the window and pane ID into the tmp ini file we are about to make, so other runs of sledjchisl can find it. +Move window and pane opening to ROBUST starting time. + So the writing of the pane ID files is also then. + Open those pane ID files also before the main loop. + So all the actions have access. Leave empty panes as is. Don't bother to close panes unless we are doing a full stop. - -Is there a "switch to pane 1" command? Nope - Ctrc A digit Move to that numbered window. - Ctrl A arrow key Move to the pane in that direction. - Ctrl A n Move to the next window. - Ctrl A p Move to the previous window. - Ctrl A w Choose the current window interactively. - Ctrl A o Move to the next pane. - Ctrl A ; Move to the previously selected pane. - Ctrl A l Move to the previously selected window. - Ctrl A Ctrl o Rotate panes"forwards". I do this accidently sometimes, coz MC. - Ctrl A Alt o Rotate panes"backwards". - Ctrl A z Toggle zooming into the current pane. +Also clear out tmp when doing afull stop. */ } - I("%s is starting up in tab [%d:%s] pane .%d, from %s/sim%d.", name, window, type, pane, scTemp, count); - - char *cmd = xmprintf("rm -fr %s/sim%d; mkdir -p %s/sim%d; sed -E" + snprintf(toybuf, sizeof(toybuf), "echo 'IDs={' >%s/IDs_%d.lua", scTemp, window); + system(toybuf); + doTmuxCmd("list-panes -t %d -F \"['%d #{pane_index}'] = '#{window_id}.#{pane_id}',\" >> %s/IDs_%d.lua", window, window, scTemp, window); + snprintf(toybuf, sizeof(toybuf), "echo '}\nreturn IDs' >>%s/IDs_%d.lua", scTemp, window); + system(toybuf); + + snprintf(toybuf, sizeof(toybuf), "%s/IDs_%d.lua", scTemp, window); + qtreetbl_t *IDs = Lua2tree(toybuf, "IDs"); + snprintf(toybuf, sizeof(toybuf), "%d %d", window, pane); + simd->paneID = qLuaGet(IDs, toybuf)->v.s; + + I("%s is starting up in tab [%d:%s](pane %d), tmux ID = %s, from %s/sim%d.", name, window, type, pane, simd->paneID, scTemp, count); simd->portH = 8004 + count * 2; simd->portU = 8005 + count * 2; + cmd = xmprintf("rm -fr %s/sim%d; mkdir -p %s/sim%d; sed -E" " -e 's@\\[Region\\]@" + " paneID = \"\\%s\"\\n" "\\[Startup\\]\\n" " PIDFile = \"\\$\\{Paths\\|CachePath\\}\\/\\$\\{Const\\|mysim\\}\\.pid\"\\n" " LogFile = \"\\$\\{Paths\\|LogPath\\}\\/OpenSim_\\$\\{Const\\|mysim\\}\\.log\"\\n" @@ -7856,6 +7856,7 @@ Is there a "switch to pane 1" command? Nope " %s >%s", scTemp, count, scTemp, count, + simd->paneID, simd->portU, simd->portU, simd->portH, @@ -7869,22 +7870,20 @@ Is there a "switch to pane 1" command? Nope E("sed command failed!"); free(cmd); - cmd = xmprintf("%d.%d", simd->window, simd->pane); - doTmuxCmd("select-pane -t %s:%s -T '%s'", Tconsole, cmd, nm); + doTmuxCmd("select-pane -t %s:%s -T '%s'", Tconsole, simd->paneID, nm); { snprintf(toybuf, sizeof(toybuf), "mono OpenSim.exe -inidirectory=%s/sim%d", scTemp, count); - sendTmuxCmd(cmd, toybuf); + sendTmuxCmd(simd->paneID, toybuf); if (0 == doWait) { snprintf(toybuf, sizeof(toybuf), "INITIALIZATION COMPLETE FOR %s", name); - waitTmuxText(cmd, toybuf); + waitTmuxText(simd->paneID, toybuf); I("%s is done starting up.", name); la = waitLoadAverage(la, loadAverageInc, simTimeOut); } count++; doWait = (count % bulkSims); } - free(cmd); free(newPath); free(path); } @@ -7974,14 +7973,11 @@ Is there a "switch to pane 1" command? Nope } } nextSim: -// if (panes) + pane++; + if (pane >= panes) { - pane++; - if (pane >= panes) - { - pane = 0; - window++; - } + pane = 0; + window++; } //if (4 < number) break; } -- cgit v1.1