Skip to content
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

hack-manager.js sleep loop? #9

Open
d4t4king opened this issue Aug 4, 2022 · 8 comments
Open

hack-manager.js sleep loop? #9

d4t4king opened this issue Aug 4, 2022 · 8 comments

Comments

@d4t4king
Copy link

d4t4king commented Aug 4, 2022

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
Copy link
Collaborator

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

@d4t4king
Copy link
Author

d4t4king commented Aug 5, 2022

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
Copy link
Author

d4t4king commented Aug 5, 2022

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
Copy link

ScroDerion commented Sep 6, 2022

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
Copy link

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
Copy link

Glarbasaur commented Mar 11, 2023

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
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants