]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/utils.js
Fix client linting
[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
9f10b292
C
20function cleanForExit (webtorrent_process) {
21 logger.info('Gracefully exiting.')
22 process.kill(-webtorrent_process.pid)
23}
0ae2e7f7 24
9f10b292 25// ---------------------------------------------------------------------------
c45f7f84 26
9f10b292 27module.exports = utils