diff --git a/.env.example b/.env.example index 82373678b0fc2ba086706524d016103639bbb4d6..7dd228e40112dd302c19f2ceee24e6b79e766578 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ GITLAB_TOKEN= -GITLAB_HOST= \ No newline at end of file +GITLAB_HOST= +TIMEOUT= \ No newline at end of file diff --git a/src/config.js b/src/config.js index 0f33d6db41b6cb76d6a8f581bba6426012930218..7254037df3eebcc28db811f8d0936994d6cc1a4e 100644 --- a/src/config.js +++ b/src/config.js @@ -4,4 +4,5 @@ require('dotenv').config({ path: path.join(__dirname, '../.env') }) module.exports = { gitlabToken: process.env.GITLAB_TOKEN, gitlabHost: process.env.GITLAB_HOST, + timeout: parseInt(process.env.TIMEOUT, 10) || 300000 }; diff --git a/src/index.js b/src/index.js index 26aea32f4abee530999c26aed41c8e9e3696eb8c..d90d4ad5eac26e65fad38d5cefee542e5b07093c 100644 --- a/src/index.js +++ b/src/index.js @@ -26,7 +26,7 @@ const api = new Gitlab({ function readStudentsFile() { if (!fs.existsSync(studentsFilePath)) { - console.error(`File ${studentsFilePath} doesn't exist`); + console.log(`File ${studentsFilePath} doesn't exist`); return []; } const data = fs.readFileSync(studentsFilePath, 'utf8'); @@ -88,9 +88,12 @@ async function main() { await addUserToProject(user.id, project.id); } catch(err) { - console.error(err); + console.log(err); } } } -main().catch(err => console.error(err)); + +setInterval(() => { + main().catch(err => console.log(err)); +}, config.timeout);