Closed morko closed 4 years ago
Ups I realized this issue should be at the haxball-headless-manager repo. Sorry.
np, I'll look into this as soon as I can.
How to reproduce this? It seems to restart the room when I call reload
.
room1> reload
LOADING CONFIG from /media/shared/source/git/haxball-headless-manager/local/haxroomie/config-testing.js
RELOAD CONFIG Rooms (room1) were modified.
CLOSING ROOM room1
ROOM CLOSED room1
STARTING ROOM room1
[…]
Does !plugin reload sav/roles
of the sav/plugin-control
plugin produce the same output?
I'll push my local changes later today, maybe it's something that has been fixed in the meantime.
Ah yes sorry ive made the changes only at the feature branch https://github.com/morko/haxroomie/tree/feature/hot-reload-plugins. To reproduce start a room with a config that doesnt have the roles plugin and then edit it to include the roles plugin and do reload
.
I think I found the problem, it becomes clear if you subscribe to the pluginRemoved
HHM event – the dependencies get loaded properly, but then this code removes all plugins not explicitly listed in the plugin config.
I'm not sure why I didn't add dependency checks in my removePlugin()
function though, I think only disabled plugins should be removable. A quick fix for this problem in your code would be calling disablePlugin(pluginName, false)
for each of the plugins not in the pluginConfig
and then checking if the returned array is empty. Only if it is not empty (i.e., if the plugin could be disabled, which is only the case if no other plugins depend on it), you would then call removePlugin()
.
I will adjust my code so that removePlugin will try to do this internally and return false if other plugins depend on it.
Oh ok thanks for debugging my mistakes then. :D I will look into it when i have time.
It now "works" in that it does not allow removal of dependencies, this leads to strange results sometimes though because depending on the order in which plugins are removed, it works or it does not work as expected.
Not sure what the cleanest way here is, but the simplest (and dumbest) way is probably iterating over the plugins that are not in the pluginConfig
and trying to remove them until nothing was removed for one iteration. :D
Or maybe going over the plugins not in the pluginConfig
and checking if they are a direct or indirect dependency of one of the plugins listed in the pluginConfig
(getDependentPlugins(pluginIdOrName, true)
), and removing them if not.
I will close this for now, maybe we can discuss how to solve this cleaner sometime, or maybe it will work if you change how you remove plugins during hot loading.
I was implementing support for the hot loading of plugins for haxroomie and when I tried to hot load
sav/roles
it produced the following log:It seems like the dependencies do not get loaded correctly even though it claims so.