Jrpl / Bitburner-Scripts

A collection of scripts written for the game Bitburner
MIT License
87 stars 33 forks source link

hack-manager.js sleep loop? #9

Open d4t4king opened 2 years ago

d4t4king commented 2 years ago

When I use hack-manager.js it fills up the queues in the Active Scripts tab. But then, after a while, it seems to "finish" and only the original hack-manager.js is running with no child scripts on other servers. If I kill hack-manager.js and run it again, it fills up the queues and makes a bunch of money, then lulls to zero again.

Would appreciate if someone could at least explain what might be going on here. Is this likely because of low server money? High security? What gives.

TIA

Riley-H-99 commented 2 years ago

Could you please send the logs of the script when it enters this inactive state?

d4t4king commented 2 years ago

Of course, now that I post about it, it doesn't go into the inactive state.

From what I remember, beccause I /did/ check the logs, it would do an available ram check then sleep and just cycle through all the servers doing that: ram check; sleep, etc. I will definitely post the logs when/if it goes back into that state.

d4t4king commented 2 years ago

This is what the log looks like during the inactive phase. I don't know if there's a way to turn up the verbosity.

sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 16.40GB
sleep: Sleeping for 1 milliseconds
ScroDerion commented 2 years ago

I am running into the same issue following the string below.

exec: Could not find script 'targeted-grow.js' on 'nectar-net'
sleep: Sleeping for 10 milliseconds
getServerMaxRam: returned 8.00GB
getServerUsedRam: returned 0.00B
exec: Could not find script 'targeted-grow.js' on 'CSEC'
sleep: Sleeping for 10 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 0.00B
exec: Could not find script 'targeted-grow.js' on 'neo-net'
sleep: Sleeping for 10 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 0.00B
exec: Could not find script 'targeted-grow.js' on 'iron-gym'
sleep: Sleeping for 10 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 0.00B
exec: Could not find script 'targeted-grow.js' on 'zer0'
sleep: Sleeping for 10 milliseconds
sleep: Sleeping for 82944.8275862071 milliseconds
MikeHunt21 commented 2 years ago

I am running into the same issue following the string below.

exec: Could not find script 'targeted-grow.js' on 'nectar-net'
sleep: Sleeping for 10 milliseconds
getServerMaxRam: returned 8.00GB
getServerUsedRam: returned 0.00B
exec: Could not find script 'targeted-grow.js' on 'CSEC'
sleep: Sleeping for 10 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 0.00B
exec: Could not find script 'targeted-grow.js' on 'neo-net'
sleep: Sleeping for 10 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 0.00B
exec: Could not find script 'targeted-grow.js' on 'iron-gym'
sleep: Sleeping for 10 milliseconds
getServerMaxRam: returned 32.00GB
getServerUsedRam: returned 0.00B
exec: Could not find script 'targeted-grow.js' on 'zer0'
sleep: Sleeping for 10 milliseconds
sleep: Sleeping for 82944.8275862071 milliseconds

Change all the ns.scp "await ns.scp('targeted-weaken.js', "home" , server)" to "await ns.scp('targeted-weaken.js', server , 'home')"

Glarbasaur commented 1 year ago

The last two replies are for a separate problem. The scp parameter order is switched, and


weaken_threads = Math.floor(weaken_threads);
hack_threads = Math.floor(hack_threads);```
Needs to be added at line 430, just before the final 3 ns.exec() to ensure threads are integers and not floats. 

But having done that, I'm still getting an infinite sleep loop like the one d4t4king posted. Repeatedly showing 
```sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 1.45TB
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 1.45TB
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 1.45TB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 1.45TB
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 1.45TB
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 1.45TB
sleep: Sleeping for 1 milliseconds```
and never refills the queues. It sat for at least 10 minutes. It works if it's killed and re-run.
Glarbasaur commented 1 year ago

I couldn't find where these calls were coming from, but I inserted ns.print()s and found theyre at


194
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 897.60GB
211
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 897.60GB
sleep: Sleeping for 1 milliseconds
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 897.60GB
172
194
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 897.60GB
211
getServerMaxRam: returned 2.05TB
getServerUsedRam: returned 897.60GB
sleep: Sleeping for 1 milliseconds```
Glarbasaur commented 1 year ago

Solved it. Need to apple Math.floor() to hack_threads, weaken_threads, and grow_threads at line 173, before the first if in the whileloop. If you dont, they can be an arbitrarily small number like 0.08375643, which is too small for a single thread, and itll catch you in the loop. and since youve used up as much space as possible in the first iteration, you always get a number <1.