BeBot - An Anarchy Online and Age Of Conan chat automaton

General => General discussion => Topic started by: Dochere on April 16, 2010, 07:48:02 am

Title: Reloading module while running?
Post by: Dochere on April 16, 2010, 07:48:02 am
Would it be possible to reload a module while bot is running in any way?



I'm adding ALOT of new features to the bot I'm running, and honestly people on it ain't too happy with me updating the bot several times a day. With about 500 active members (2600 total) and about 60 of those are in the group channel at any given time, they are starting to get tired of all my quick restarts. (heh not like i do this every day, but the days when im pushing out new updates)


I have 2 bots, bot #2 is a backupbot that i use to develop mods before they go live. So about 9 of 10 times mods working on backupbot requires no modifications to run on the live bot. So in theory reloading the module should not produce any errors.


/Dochere
Title: Re: Reloading module while running?
Post by: Yite on April 16, 2010, 09:50:59 am
Loading a module is not an issue while the bot is running. However PHP provides no way for us to unload current functions and classes afaik.

This has been discussed internally in the past, and the verdict was that it's simply not possible to do within the constraints PHP gives us.
Title: Re: Reloading module while running?
Post by: Dochere on April 16, 2010, 11:11:16 am
Oh thanks, I knew I had read somewere that it was not possible but I could not find it when I was looking for it earlier.
Title: Re: Reloading module while running?
Post by: Kyr on April 16, 2010, 07:50:08 pm
I have a second bot running as silently as possible that I use when testing modules.  Doesn't give any messages when people log in or level or anything like that.  I only have it running when I am testing something new.  Then once I finish the testing I move the module over to the real bot and restart just the one time.
Title: Re: Reloading module while running?
Post by: Dochere on April 17, 2010, 01:21:48 am
Same as i do, though not all modules i wirte can be tested with dryrun. Actually most mods iwe done cannot be tested on the devbot. But yeah i try to keep it at a minimum on the live bot.
Title: Re: Reloading module while running?
Post by: Vhab on April 17, 2010, 09:04:45 am
I've been cracking my head over this one too (as it's a very interesting problem actually).

If only PHP had anonymous classes or a way to 'free up'/unload a class name (knowing I already got rid of all references myself), then I'm certain I could make run-time loading/reloading work.
I do have a few other ideas floating in the back of my head, but it would likely change the way plugins work.

But there is a 'next best thing' while you're devving.
Take the content of a method you're heavily editing, put it in a separate file and include that file from your plugins' method.
This will cause the code to be read on each call and will always use the latest version of your code.
Title: Re: Reloading module while running?
Post by: Dochere on June 04, 2010, 10:00:25 am
Hers an idea:


Raid channel ran by 2 bots.

Bot 1: Private Group Bot, this bot only keeps the channel alive and invites people.
Bot 2: Modules Bot, does all other tasks that bot 1 would normally do.


Now you could restart Bot 2 without having shut channel down. And all the uses would see is that "Bot 2 left the channel. Bot 2 has joined the channel." And Bot 1 would basically never needed to be restarted as it only runs a few core functions.
SimplePortal 2.3.7 © 2008-2024, SimplePortal