HtheChemist / BitBurnerCentralManager

A prototype thread manager for BitBurner
MIT License
26 stars 12 forks source link

TargetManager doesn't pick up on new bought server. #5

Closed jsievertde closed 2 years ago

jsievertde commented 2 years ago

Hello,

there seems to be a bug with new servers as the servers name remains the same and won't be picked up by the TargetManager to get the scripts deployed. As such the hacks, grows and weakens will run int the error exec: Could not find script A simple solution would be to give all servers an UUID as unique name part and then the TargetManager should always find a new ones.

Or am i missing something in the code ? If you want i could code the relevant section in the ServerManager and push a pull request ?

HtheChemist commented 2 years ago

I just noticed this this morning, I also found out that target manager would not update its available port opening program. The UUID idea is good however we must ensure that older server are removed from the list also. A possible way would be to write a file with a random name each time the Target Manager is booted, check for the presence of the file and if they are the right version based on the randomly named file.

jsievertde commented 2 years ago

Hmm but then the ServerManager should delete that file so that the ThreadManager rebuilds the Threadcount.

But the old Servers woudl still be in the list for inclusion or should the `TargetManager then be told to rerun the scan of all hosts ?

jsievertde commented 2 years ago

Or would it be simpler to also send a message to the TargetManager and just tell it to redeploy everything to the new Server?

That could be the easiest way to do this.

Just a new function in the TargetManager that is listening for the message and then just trigger this part of the code again:

if (host !== "home" && host !== HACKING_SERVER && host !== MANAGING_SERVER) {
     for (let j = 0; j < Object.values(HACKING_SCRIPTS).length; j++) {
                            const script: string = Object.values(HACKING_SCRIPTS)[j]
                            ns.rm(script, host)
                            await ns.scp(script, "home", host);
                        }
                        for (let j = 0; j < IMPORT_TO_COPY.length; j++) {
                            const script: string = IMPORT_TO_COPY[j]
                            ns.rm(script, host)
                            await ns.scp(script, "home", host);
                        }
                    }
HtheChemist commented 2 years ago

That could be a great option, I was planning to add a function on the TargetManager to allow retrieval of the current list.

The target manager kind of already re-scan all host, but skip those who are already on its list. Alternatively, the ServerManager could send a delete request to the TargetManager that would remove the server from the list, this way it would be rebuilt in the next scan cycle. There may be a race condition here as the ThreadManager would assign thread probably faster than the TargetManager cycle and upload the file.

I have implemented an update function in the ThreadManager for this case, I could probably go a similar way.

HtheChemist commented 2 years ago

Solved. I ended up doing a shared function, Server Manager manage the copying of the file. I also added a console function to watch the status of the Thread Manager, "threadsUse". Threads also deallocate correctly.