Commit 3205978a authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 62d9b746
...@@ -17,6 +17,13 @@ async function init() { ...@@ -17,6 +17,13 @@ async function init() {
catch (e) catch (e)
{ {
}
try {
await fs.mkdirSync('work')
}
catch (e)
{
} }
try { try {
await fs.mkdirSync('detailsJson') await fs.mkdirSync('detailsJson')
...@@ -31,12 +38,12 @@ async function init() { ...@@ -31,12 +38,12 @@ async function init() {
for (let i = 0; i < cores; i++) { for (let i = 0; i < cores; i++) {
let res = await fs.existsSync(prefix + i) let res = await fs.existsSync('work/'+prefix + i)
if (!res) { if (!res) {
await fs.mkdirSync(prefix + i) await fs.mkdirSync('work/'+prefix + i)
} }
await makeStatus(prefix + i) await makeStatus('work/'+prefix + i)
} }
...@@ -172,7 +179,7 @@ function writeFileDetail( data) { ...@@ -172,7 +179,7 @@ function writeFileDetail( data) {
async function findOffWorker() { async function findOffWorker() {
let arr = [] let arr = []
for (let i = 0; i < cores; i++) { for (let i = 0; i < cores; i++) {
let res = await fs.readFileSync('./' + prefix + i + '/work.txt', 'utf8'); let res = await fs.readFileSync('./work/' + prefix + i + '/work.txt', 'utf8');
if (res.includes('0')) if (res.includes('0'))
arr.push(prefix + i) arr.push(prefix + i)
......
...@@ -24,12 +24,12 @@ async function init() { ...@@ -24,12 +24,12 @@ async function init() {
for (let i = 0; i < cores; i++) { for (let i = 0; i < cores; i++) {
let res = await fs.existsSync(prefix + i) let res = await fs.existsSync('work/'+prefix + i)
if (!res) { if (!res) {
await fs.mkdirSync(prefix + i) await fs.mkdirSync('work/'+prefix + i)
} }
await makeStatus(prefix + i) await makeStatus('work'+prefix + i)
} }
...@@ -173,7 +173,7 @@ function makeStatusNew(directory, status) { ...@@ -173,7 +173,7 @@ function makeStatusNew(directory, status) {
async function findOffWorker() { async function findOffWorker() {
let arr = [] let arr = []
for (let i = 0; i < cores; i++) { for (let i = 0; i < cores; i++) {
let res = await fs.readFileSync('./' + prefix + i + '/work.txt', 'utf8'); let res = await fs.readFileSync('./work/' + prefix + i + '/work.txt', 'utf8');
if (res.includes('0')) if (res.includes('0'))
arr.push(prefix + i) arr.push(prefix + i)
......
...@@ -38,7 +38,7 @@ async function run() { ...@@ -38,7 +38,7 @@ async function run() {
checks = await fs.readFileSync('./detail.json', 'utf8') checks = await fs.readFileSync('./detail.json', 'utf8')
configs = JSON.parse(configs) configs = JSON.parse(configs)
let arr = [] let arr = []
let files = await fs.readdirSync('./' + directory) let files = await fs.readdirSync('./work/' + directory)
for (let i = 0; i < files.length; i++) for (let i = 0; i < files.length; i++)
if (files[i].includes('.csv')) { if (files[i].includes('.csv')) {
...@@ -378,7 +378,7 @@ async function test2() { ...@@ -378,7 +378,7 @@ async function test2() {
function makeStatus(directory, status) { function makeStatus(directory, status) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
fs.writeFile(directory + '/work' + '.txt', status, 'utf8', function (err) { fs.writeFile('work/'+directory + '/work' + '.txt', status, 'utf8', function (err) {
if (err) reject(err); if (err) reject(err);
else resolve(true); else resolve(true);
}); });
......
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