Created
November 19, 2014 20:17
-
-
Save alanhoff/5a911b5cc9f2e500cc10 to your computer and use it in GitHub Desktop.
Rodar apenas uma vez
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rodando = false; | |
var minhaFunc = function(){ | |
if(rodando) | |
return; // Já está rodando | |
rodando = true; | |
db.query('select 1 + 1 as result', function(err, result){ | |
rodando = false; | |
if(err) | |
throw err; | |
console.log(result); | |
}); | |
}; | |
// Rodar essa função a cada segundo | |
setInterval(minhaFunc, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment