Commit 947f8bc7 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 6830d7cf
...@@ -20,7 +20,7 @@ async function init() ...@@ -20,7 +20,7 @@ async function init()
await fs.mkdirSync(prefix + i) await fs.mkdirSync(prefix + i)
} }
makeStatus(prefix + i) await makeStatus(prefix + i)
} }
...@@ -50,9 +50,15 @@ async function check() ...@@ -50,9 +50,15 @@ async function check()
continue continue
let worker=await findOffWorker() let worker=await findOffWorker()
console.log(worker) // console.log(worker)
if (worker !==null)
{
await fs.renameSync('files/'+files[i],worker+'/'+files[i]) await fs.renameSync('files/'+files[i],worker+'/'+files[i])
await makeStatusNew(worker,'1')
shell.exec('node run.js '+worker, {async: true}); shell.exec('node run.js '+worker, {async: true});
}
} }
...@@ -65,6 +71,16 @@ async function check() ...@@ -65,6 +71,16 @@ async function check()
} }
function makeStatusNew(directory, status) {
return new Promise(function (resolve, reject) {
fs.writeFile(directory + '/work' + '.txt', status, 'utf8', function (err) {
if (err) reject(err);
else resolve(true);
});
});
}
async function findOffWorker() async function findOffWorker()
{ {
...@@ -80,4 +96,6 @@ async function findOffWorker() ...@@ -80,4 +96,6 @@ async function findOffWorker()
if (arr.length !==0) if (arr.length !==0)
return arr[0] return arr[0]
else return null
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment