• Visit Rebornbuddy
  • recompiling and reloading post-launch?

    Discussion in 'Community Developer Forum' started by Zimble, Mar 3, 2020.

    1. Zimble

      Zimble Member

      Joined:
      Oct 26, 2012
      Messages:
      66
      Likes Received:
      1
      Trophy Points:
      8
      I've written a plugin to handle updating botbases/plugins/routines from a repo and have reached a state where it's functional. https://github.com/Zimgineering/repoBuddy

      Does anyone know how to recompile and reload a single botbase/plugin/routine while rebornbuddy is running? I've messed with the reloadonfilechange flags in the globalsettings but those don't seem to be what I need. (nor do they work in all cases, eg exbuddy because of threading)

      At the moment I'm handling the restarts like this:
      Code:
      private void RestartRebornBuddy()
      {           
          AppDomain.CurrentDomain.ProcessExit += new EventHandler(RebornBuddy_Exit);
         
          void RebornBuddy_Exit (object sender, EventArgs e)
          {
              Process.Start("rebornbuddy", "-a"); //autologin using stored key
          }
         
          Process process = Process.GetCurrentProcess();
          process.CloseMainWindow();
      }
      
      
      But that has the obvious caveat of taking more time and writes to the drive as well as essentially making log messages invisible.

      Is there a more elegant solution I'm missing, or would I be better off using a preloader?
       
    2. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      4,555
      Likes Received:
      237
      Trophy Points:
      63
      reloadonfilechange is really the only "supported" way, and it's a giant hack.

      You could store log messages in setting, replay them after the restart, also increment a counter or state (inside the setting class) indicating that it was a restart to prevent chain restarting incase something goes wrong.

      Don't worry about writes to drives, the impact is immeasurable.

      As for a preloader im not sure what you mean.
       
    3. Zimble

      Zimble Member

      Joined:
      Oct 26, 2012
      Messages:
      66
      Likes Received:
      1
      Trophy Points:
      8
      Good solution for the log messages, is there a way to detect when all components are loaded without specifically targeting a routine or the generic routinesloaded event? Is there any way to get a plugins directory after compile? I have the svn dll hardcoded and that could cause issues for some people.

      I have bool restartNeeded initialized as false that gets set to true after a non profile update so I don't loop but I can see why storing it in the settings file could be better. By preloader I just meant something that you run in lieu of rb to update the components and then launch rb, potentially cutting total load time by near half. I've written a bat file to handle this using visualsvn but I really wanted a handsfree solution.
      comma delimited batrepos.txt:
      Plugins,ExBuddy,https://github.com/Entrax643/ExBuddy.git/trunk/ExBuddy
      Code:
      @echo off
      setlocal enabledelayedexpansion
      set RB_Dir=.
      set SVN=.\bin\svn.exe
      
      echo RebornBuddy directory set to %RB_Dir%
      echo SVN directory set to %SVN%
      echo Updating Repos
      for /f "usebackq tokens=1-3 delims=," %%A in ("batrepos.txt") do ( if exist ./%%A/%%B/.svn (start /b %SVN% update ./%%A/%%B --accept tf) else (start /b %SVN% checkout %%C ./%%A/%%B))
      
      :whileSVN
      TASKLIST | FINDSTR /I "svn.exe" >nul && goto :whileSVN
      
      start %RB_Dir%\rebornbuddy.exe -a
      exit
       
      Last edited: Mar 3, 2020
    4. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      4,555
      Likes Received:
      237
      Trophy Points:
      63
      You could do something hacky like doing some reflection on the hotkeymanager class and checking the private bool if its been set to true, thats one of the final things done during initialization.

      No way to map plugin to directory either
       
    5. Zimble

      Zimble Member

      Joined:
      Oct 26, 2012
      Messages:
      66
      Likes Received:
      1
      Trophy Points:
      8
      Looks like I've got it about as good as it can get then, thanks!
       

    Share This Page