Fixed some bugs
This commit is contained in:
parent
7e5bd3031a
commit
3374e80607
@ -81,7 +81,7 @@ export async function main(ns) {
|
|||||||
await ns.sleep(500);
|
await ns.sleep(500);
|
||||||
}
|
}
|
||||||
ns.killall(args['server']);
|
ns.killall(args['server']);
|
||||||
const pid = ns.exec(args['file'], args['server'], threads, args['args']);
|
const pid = ns.exec(args['file'], args['server'], threads, ...args['args']);
|
||||||
if(!args['quite']) {
|
if(!args['quite']) {
|
||||||
ns.tprint(!!pid ? 'Done!' : 'Failed to start');
|
ns.tprint(!!pid ? 'Done!' : 'Failed to start');
|
||||||
ns.tprint('');
|
ns.tprint('');
|
||||||
|
@ -86,6 +86,11 @@ export async function main(ns) {
|
|||||||
|
|
||||||
// Start script if required
|
// Start script if required
|
||||||
if(args['script']) {
|
if(args['script']) {
|
||||||
|
const threads = args['cpu'] || maxThreads(ns, args['script'], args['server']);
|
||||||
|
if(!threads) {
|
||||||
|
ns.tprint(`Server does not have enough RAM to start script.`);
|
||||||
|
ns.exit();
|
||||||
|
}
|
||||||
// Copy script & it's dependencies
|
// Copy script & it's dependencies
|
||||||
const files = await copyWithDependencies(ns, args['script'], args['server']);
|
const files = await copyWithDependencies(ns, args['script'], args['server']);
|
||||||
if(!args['quite']) {
|
if(!args['quite']) {
|
||||||
@ -95,14 +100,13 @@ export async function main(ns) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start the script
|
// Start the script
|
||||||
const threads = args['cpu'] || maxThreads(ns, args['file'], args['server']) || 1;
|
|
||||||
if(!args['quite']) {
|
if(!args['quite']) {
|
||||||
ns.tprint('');
|
ns.tprint('');
|
||||||
ns.tprint(`Executing with ${threads} thread${threads > 1 ? 's' : ''}...`);
|
ns.tprint(`Executing with ${threads} thread${threads > 1 ? 's' : ''}...`);
|
||||||
await ns.sleep(500);
|
await ns.sleep(500);
|
||||||
}
|
}
|
||||||
ns.killall(args['server']);
|
ns.killall(args['server']);
|
||||||
const pid = ns.exec(args['file'], args['server'], threads, args['args']);
|
const pid = ns.exec(args['script'], args['server'], threads, ...args['args']);
|
||||||
if(!args['quite']) {
|
if(!args['quite']) {
|
||||||
ns.tprint(!!pid ? 'Done!' : 'Failed to start');
|
ns.tprint(!!pid ? 'Done!' : 'Failed to start');
|
||||||
ns.tprint('');
|
ns.tprint('');
|
||||||
|
@ -52,7 +52,7 @@ export async function main(ns) {
|
|||||||
ns.purchaseServer(`${serverPrefix}${servers.length}`, args['ram']);
|
ns.purchaseServer(`${serverPrefix}${servers.length}`, args['ram']);
|
||||||
|
|
||||||
// Run the script if requested
|
// Run the script if requested
|
||||||
if(args['script']) await startScript(`${serverPrefix}${servers.length - 1}`);
|
if(args['script']) await startScript(`${serverPrefix}${servers.length}`);
|
||||||
} else { // Check for upgrades
|
} else { // Check for upgrades
|
||||||
let upgrades = servers.map(server => {
|
let upgrades = servers.map(server => {
|
||||||
// Calculate next RAM upgrades (must be a power of two: 2, 4, 8, 16, 32...)
|
// Calculate next RAM upgrades (must be a power of two: 2, 4, 8, 16, 32...)
|
||||||
|
Loading…
Reference in New Issue
Block a user