aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authoronefang2021-08-13 03:26:48 +1000
committeronefang2021-08-13 03:26:48 +1000
commit4d2a2b12eab527b4a81309234b707a076bf693af (patch)
treee36e821d8f2f13b973a1eb5a444dd3ba5b166836 /src
parentOops, need this for the option display. (diff)
downloadopensim-SC-4d2a2b12eab527b4a81309234b707a076bf693af.zip
opensim-SC-4d2a2b12eab527b4a81309234b707a076bf693af.tar.gz
opensim-SC-4d2a2b12eab527b4a81309234b707a076bf693af.tar.bz2
opensim-SC-4d2a2b12eab527b4a81309234b707a076bf693af.tar.xz
Restart sims.
Diffstat (limited to 'src')
-rw-r--r--src/sledjchisl/sledjchisl.c96
1 files changed, 56 insertions, 40 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index d8b78e6..7180383 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -1769,6 +1769,54 @@ void findSimsTmux(simData *simd, char *sim, char *type, int count, int window, i
1769 freeLuaTree(IDs); 1769 freeLuaTree(IDs);
1770} 1770}
1771 1771
1772void startSim(simData *simd, char *sim, char *type, int count, int window, int panes, int pane)
1773{
1774 if (!checkSimIsRunning(simd->tab))
1775 {
1776 I("Tmux tab [%d:%s](pane %d) tmux ID %s, from %s/sim%d - %s is starting.", window, type, pane, simd->paneID, scTemp, count, simd->name);
1777 doTmuxCmd("select-pane -t %s:%s -T '%s'", Tconsole, simd->paneID, simd->tab);
1778 snprintf(toybuf, sizeof(toybuf), "mono OpenSim.exe -inidirectory=%s/sim%d", scTemp, count);
1779 sendTmuxCmd(simd->paneID, toybuf);
1780 if (0 == ourSims->doIt)
1781 {
1782 snprintf(toybuf, sizeof(toybuf), "INITIALIZATION COMPLETE FOR %s", simd->name);
1783 waitTmuxText(simd->paneID, toybuf);
1784 I("%s is done starting up.", simd->name);
1785 ourSims->la = waitLoadAverage(ourSims->la, loadAverageInc, simTimeOut);
1786 if (1 < bulkSims)
1787 bulkSims = bulkSims / 2;
1788 }
1789 else
1790 {
1791// TODO - some compromise, do a premptive load check if we are not doing a wait anyway.
1792 }
1793 ourSims->doIt = ((count + 1) % bulkSims);
1794 }
1795}
1796
1797void stopSim(simData *simd, char *sim, char *type, int count, int window, int panes, int pane)
1798{
1799 if (checkSimIsRunning(simd->tab))
1800 {
1801 // Leave empty panes as is.
1802// TODO - should check if there's people there, but don't count NPCs. alert them, wait a while, or just abort the stop.
1803 sendTmuxCmd(simd->paneID, "quit");
1804 // There's three things that might happen -
1805 // Sim will quit, tmux pane will go away before we can see the shutdown message.
1806 // pane-exited hook might be useful here.
1807 // Sim will quit, tmux pane wont go away. Dunno yet if waitTmuxText() will still work.
1808 // pane-died hook might be useful here.
1809 // Sim fails to quit, error message on the pane that we want to read, wont see the shutdown message.
1810 // Also sim might not have finished starting up, and may even not be accepting comands yet.
1811// TODO - cater for and test them all.
1812// Could also loop on checkSimIsRunning(sim)
1813// snprintf(toybuf, sizeof(toybuf), "[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
1814// waitTmuxText(nm, toybuf);
1815// I("%s is done stopping.", simd->name);
1816// la = waitLoadAverage(la, loadAverageInc, simTimeOut);
1817 }
1818}
1819
1772void doSimsThing(simData *simd, char *sim, char *type, int count, int window, int panes, int pane) 1820void doSimsThing(simData *simd, char *sim, char *type, int count, int window, int panes, int pane)
1773{ 1821{
1774 // Check if only doing a single sim. 1822 // Check if only doing a single sim.
@@ -1798,27 +1846,7 @@ void doSimsThing(simData *simd, char *sim, char *type, int count, int window, in
1798 { 1846 {
1799 case START : // "start 'Welcome sim'" "start Welcome.shini" "Welcome.shini" "start Welcome.ini" "start Welcome" "start" start everything 1847 case START : // "start 'Welcome sim'" "start Welcome.shini" "Welcome.shini" "start Welcome.ini" "start Welcome" "start" start everything
1800 { 1848 {
1801 if (!checkSimIsRunning(simd->tab)) 1849 startSim(simd, sim, type, count, window, panes, pane);
1802 {
1803 I("Tmux tab [%d:%s](pane %d) tmux ID %s, from %s/sim%d - %s is starting.", window, type, pane, simd->paneID, scTemp, count, simd->name);
1804 doTmuxCmd("select-pane -t %s:%s -T '%s'", Tconsole, simd->paneID, simd->tab);
1805 snprintf(toybuf, sizeof(toybuf), "mono OpenSim.exe -inidirectory=%s/sim%d", scTemp, count);
1806 sendTmuxCmd(simd->paneID, toybuf);
1807 if (0 == ourSims->doIt)
1808 {
1809 snprintf(toybuf, sizeof(toybuf), "INITIALIZATION COMPLETE FOR %s", simd->name);
1810 waitTmuxText(simd->paneID, toybuf);
1811 I("%s is done starting up.", simd->name);
1812 ourSims->la = waitLoadAverage(ourSims->la, loadAverageInc, simTimeOut);
1813 if (1 < bulkSims)
1814 bulkSims = bulkSims / 2;
1815 }
1816 else
1817 {
1818// TODO - some compromise, do a premptive load check if we are not doing a wait anyway.
1819 }
1820 ourSims->doIt = ((count + 1) % bulkSims);
1821 }
1822 break; 1850 break;
1823 } 1851 }
1824 1852
@@ -1866,6 +1894,12 @@ void doSimsThing(simData *simd, char *sim, char *type, int count, int window, in
1866 1894
1867 case RESTART : // "restart 'Welcome sim'" "restart Welcome.shini" "Welcome.shini restart" "restart Welcome.ini" "restart Welcome" "restart" restart everything 1895 case RESTART : // "restart 'Welcome sim'" "restart Welcome.shini" "Welcome.shini restart" "restart Welcome.ini" "restart Welcome" "restart" restart everything
1868 { 1896 {
1897 I("Tmux tab [%d:%s](pane %d) tmux ID %s, from %s/sim%d - %s is stopping.", window, type, pane, simd->paneID, scTemp, count, simd->name);
1898 stopSim(simd, sim, type, count, window, panes, pane);
1899 while (checkSimIsRunning(simd->tab))
1900 usleep(100000);
1901 usleep(100000);
1902 startSim(simd, sim, type, count, window, panes, pane);
1869 break; 1903 break;
1870 } 1904 }
1871 1905
@@ -1881,25 +1915,7 @@ void doSimsThing(simData *simd, char *sim, char *type, int count, int window, in
1881 1915
1882 case STOP : // "stop 'Welcome sim'" "stop Welcome.shini" "Welcome.shini stop" "stop Welcome.ini" "stop Welcome" "stop" stop everything 1916 case STOP : // "stop 'Welcome sim'" "stop Welcome.shini" "Welcome.shini stop" "stop Welcome.ini" "stop Welcome" "stop" stop everything
1883 { 1917 {
1884 if (checkSimIsRunning(simd->tab)) 1918 stopSim(simd, sim, type, count, window, panes, pane);
1885 {
1886 // Leave empty panes as is.
1887// TODO - should check if there's people there, but don't count NPCs. alert them, wait a while, or just abort the stop.
1888 sendTmuxCmd(simd->paneID, "quit");
1889 // There's three things that might happen -
1890 // Sim will quit, tmux pane will go away before we can see the shutdown message.
1891 // pane-exited hook might be useful here.
1892 // Sim will quit, tmux pane wont go away. Dunno yet if waitTmuxText() will still work.
1893 // pane-died hook might be useful here.
1894 // Sim fails to quit, error message on the pane that we want to read, wont see the shutdown message.
1895 // Also sim might not have finished starting up, and may even not be accepting comands yet.
1896// TODO - cater for and test them all.
1897// Could also loop on checkSimIsRunning(sim)
1898// snprintf(toybuf, sizeof(toybuf), "[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
1899// waitTmuxText(nm, toybuf);
1900// I("%s is done stopping.", simd->name);
1901// la = waitLoadAverage(la, loadAverageInc, simTimeOut);
1902 }
1903 break; 1919 break;
1904 } 1920 }
1905 1921