]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/utils.js
Update to Angular RC 1
[github/Chocobozzz/PeerTube.git] / server / helpers / utils.js
CommitLineData
9f10b292 1'use strict'
8c308c2b 2
cbe2f7c3
C
3const crypto = require('crypto')
4
f0f5567b 5const logger = require('./logger')
8c308c2b 6
f0f5567b 7const utils = {
cbe2f7c3
C
8 cleanForExit: cleanForExit,
9 generateRandomString: generateRandomString
10}
11
12function generateRandomString (size, callback) {
13 crypto.pseudoRandomBytes(size, function (err, raw) {
14 if (err) return callback(err)
15
16 callback(null, raw.toString('hex'))
17 })
9f10b292 18}
8c308c2b 19
bc503c2a 20function cleanForExit (webtorrentProcess) {
9f10b292 21 logger.info('Gracefully exiting.')
bc503c2a 22 process.kill(-webtorrentProcess.pid)
9f10b292 23}
0ae2e7f7 24
9f10b292 25// ---------------------------------------------------------------------------
c45f7f84 26
9f10b292 27module.exports = utils