-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect config changes on the fly #3588
Comments
wow, this is a good feature, but if you do that, I will recommend setting the update for every cycle for every like 15 minutes. because if you check it every cycle it will overhead. I think haha. or you can just use keyboard input to check the config. but hey that's a good feature. |
There are possibilities to do this in python on linux, don't know how mac and windows compare. |
hoo, so you get "notice" the file is changing, and then restart the bot. love to see that happen. if i want to just farming pokeball, i need to delete catch task, after get enough pokebal i put the task back. |
@fari-99 exactly my thought. |
This is possible on Windows, one of the Po-Go-Map projects had this enabled, though it may have been due to debugging being enabled. |
I haven't touched windows in over two years, let alone did stuff to it (aka wrote something) at all. So I wouldn't know Just wanted to give some input :F |
Necro does this, so it's def possible on win, just may not be in python |
Just attach it to the relog cycle. Bot already has a login recycle event every 30 minutes or so, just re-read configuration when logging back in. |
I wouldn't want to wait for a relog cycle to be honest... I'm currently investigating a use case for a different app I work on, this shouldn't be too hard from what I gather... |
I already did this with with following changes: def initialize(bot, config):
tree = TreeConfigBuilder(bot, config.raw_tasks).build()
bot.workers = tree
bot.metrics.capture_stats()
bot.health_record = BotEvent(config)
bot.config_file = config_file
def check_config_modification(config_file):
mtime = [os.stat(config_file).st_mtime]
config_file = config_file
def check_cfg():
mdate = os.stat(config_file).st_mtime
if mtime[0] == mdate: # mtime didnt change
return False
else:
mtime[0] = mdate
return True
return check_cfg Inside loop, i think there should be a delay beetween checks, but just fast work-around. while not finished:
try:
bot = PokemonGoBot(config)
bot.start()
initialize(bot, config)
config_changed = check_config_modification(config_file)
bot.event_manager.emit(
'bot_start', sender=bot,
level='info', formatted='Starting bot...'
)
while True:
bot.tick()
if config_changed():
logger.info('Config changed! Re-apply configuration.')
config, _ = init_config()
if config:
initialize(bot, config)
else:
logger.info('Check your configration!') Maybe this will broke some bot logic - im totally new to this project. |
@sohje do you mind creating a pull request? The devs will review it before merging so you can get feedback on if it breaks anything or not |
Merged |
New bot user, following development for two weeks now...
I'm still tinkering with the bot, tweaking config here and there... which leads me to my request...
Is it possible to have to bot monitor the config and actually reload it when parts like release, recycling config or tasks to run have changed without having to restart?
The text was updated successfully, but these errors were encountered: