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
FROM fluent/fluentd:v1.3-debian | |
RUN /usr/local/bin/fluent-gem install gelf | |
WORKDIR /fluentd | |
COPY out_gelf.rb /fluentd/plugins | |
COPY ./fluent.conf /fluentd/etc/fluent.conf |
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
version: '2' | |
services: | |
mongo: | |
image: mongo:3 | |
tty: true | |
networks: | |
- logsystem | |
volumes: | |
- mongo_data:/data/db |
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
<match graylog2.**> | |
@type copy | |
<store> | |
@type gelf | |
host graylog.example.com | |
port 12201 | |
flush_interval 5s | |
</store> | |
</match> |
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
setTimeout(() => console.log('timeout1')); | |
setTimeout(() => { | |
console.log('timeout2') | |
Promise.resolve().then(() => console.log('promise resolve')) | |
}); | |
setTimeout(() => console.log('timeout3')); | |
setTimeout(() => console.log('timeout4')); |
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
setImmediate(() => console.log('immediate1')); | |
setImmediate(() => { | |
console.log('immediate2') | |
Promise.resolve().then(() => console.log('promise resolve')) | |
}); | |
setImmediate(() => console.log('immediate3')); | |
setImmediate(() => console.log('immediate4')); |
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
setImmediate(() => console.log('timeout1')); | |
setImmediate(() => { | |
console.log('timeout2') | |
process.nextTick(() => console.log('next tick')) | |
}); | |
setImmediate(() => console.log('timeout3')); | |
setImmediate(() => console.log('timeout4')); |
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
function processUsers() { | |
try { | |
const body = await client.get('http://example.com/users'); | |
const users = body.users || []; | |
// do something with users | |
} catch (err) { | |
// handle error | |
} | |
} |
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
class UserServiceError extends Error { | |
constructor(...args) { | |
super(...args); | |
this.code = 'ERR_USER_SERVICE'; | |
this.name = 'UserServiceError'; | |
this.stack = `${this.message}\n${new Error().stack}`; | |
} | |
} | |
class InvalidInputError extends Error { |
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
async function getUsers() { | |
try { | |
return getUsersFromApi(); | |
} catch (err) { | |
logger.error(err); | |
throw err; | |
} | |
} | |
router.get('/users', async (req, res) => { |
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
process.on('uncaughtException', (err) => { | |
logger.fatal('an uncaught exception detected', err); | |
}); | |
process.on('unhandledRejection', (err) => { | |
logger.fatal('an unhandled rejection detected', err) | |
}); |