Skip to content

Commit

Permalink
Fixes and refinements on the last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alainbryden committed Oct 26, 2024
1 parent c866eea commit 63f77a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions autopilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,6 @@ async function checkOnRunningScripts(ns, player) {
// If we have SF4, but not level 3, instruct daemon.js to reserve additional home RAM
if ((4 in unlockedSFs) && unlockedSFs[4] < 3)
daemonArgs.push('--reserved-ram', 32 * ((unlockedSFs[4] ?? 0) == 2 ? 4 : 16));
// Open the tail window if it's the start of a new BN. Especially useful to new players.
if(getTimeInBit)
daemonArgs.push('--tail');
}

// Once stanek's gift is accepted, launch it once per reset before we launch daemon (Note: stanek's gift is auto-purchased by faction-manager.js on your first install)
Expand All @@ -535,8 +532,11 @@ async function checkOnRunningScripts(ns, player) {
daemonRelaunchMessage ??= `Relaunching daemon.js with new arguments since the current instance doesn't include all the args we want.`;
log(ns, daemonRelaunchMessage);
}
launchScriptHelper(ns, 'daemon.js', daemonArgs);
let daemonPid = launchScriptHelper(ns, 'daemon.js', daemonArgs);
daemonStartTime = Date.now();
// Open the tail window if it's the start of a new BN. Especially useful to new players.
if (getTimeInBitnode() < 1000 * 60 * 5 || homeRam == 8) // First 5 minutes, or BN1.1
ns.tail(daemonPid);
}

// Default work for faction args we think are ideal for speed-running BNs
Expand Down Expand Up @@ -839,7 +839,8 @@ function manageReservedMoney(ns, player, stocksValue) {
function shouldWeKeepRunning(ns) {
if (4 in unlockedSFs)
return true; // If we have SF4 - run always
if (homeRam == 8) {
// If we've gotten daemon.js launched, but only have 8GB ram, we must shut down for now
if (homeRam == 8 && daemonStartTime > 0) {
log(ns, `WARN: (not an actual warning, just trying to make this message stand out.)` +
`\n` + '-'.repeat(100) +
`\n\n Welcome to bitburner and thanks for using my scripts!` +
Expand All @@ -848,7 +849,6 @@ function shouldWeKeepRunning(ns) {
`\n purchase some home RAM (which you must do manually at a store like [alpha ent.] in the city),` +
`\n\n Once you have more home ram, feel free to 'run ${ns.getScriptName()}' again!` +
`\n\n` + '-'.repeat(100), true);
ns.tail(getFilePath('daemon.js'));
return false; // Daemon.js needs more room to breath
}
// Otherwise, keep running
Expand Down
3 changes: 2 additions & 1 deletion daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ async function tryRunTool(ns, tool) {
}
const args = funcResultOrValue(tool.args) || []; // Support either a static args array, or a function returning the args.
const lowHomeRam = homeServer.totalRam(true) < 32; // Special-case. In early BN1.1, when home RAM is <32 GB, allow certain scripts to be run on any host
const runResult = lowHomeRam ? await arbitraryExecution(ns, tool, 1, args, backupServerName) :
const runResult = lowHomeRam ?
await arbitraryExecution(ns, tool, 1, args, allHostNames.includes(backupServerName) ? backupServerName : daemonHost) :
await exec(ns, tool.name, daemonHost, tool.runOptions, ...args);
if (runResult) {
runningOnServer = await whichServerIsRunning(ns, tool.name, false);
Expand Down
2 changes: 1 addition & 1 deletion helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ export async function instanceCount(ns, onHost = "home", warn = true, tailOtherI
log(ns, `WARNING: You cannot start multiple versions of this script (${scriptName}). Please shut down the other instance first.` +
(tailOtherInstances ? ' (To help with this, a tail window for the other instance will be opened)' : ''), true, 'warning');
if (tailOtherInstances) // Tail all but the last pid, since it will belong to the current instance (which will be shut down)
otherInstances.slice(0, others.length - 1).forEach(pid => ns.tail(pid));
otherInstances.slice(0, otherInstances.length - 1).forEach(pid => ns.tail(pid));
}
return otherInstances.length;
}
Expand Down

0 comments on commit 63f77a7

Please sign in to comment.