Merge branch 'next-release' of https://github.com/vatesfr/xo-server into next-release

This commit is contained in:
Varchar38 2015-06-18 16:55:08 +02:00
commit 2c05e606c7
7 changed files with 30 additions and 29 deletions

View File

@ -1,5 +1,6 @@
language: node_js
node_js:
- 'iojs'
- 'iojs-v2'
- 'iojs-v1'
- '0.12'
- '0.10'

View File

@ -80,14 +80,13 @@
"then-redis": "~1.3.0",
"trace": "^1.2.0",
"ws": "~0.7.1",
"xen-api": "^0.5.4",
"xen-api": "^0.5.6",
"xml2js": "~0.4.6",
"xo-collection": "^0.3.2"
},
"devDependencies": {
"babel-eslint": "^3.1.9",
"babel-plugin-closure-elimination": "0.0.1",
"chai": "~2.1.2",
"dependency-check": "^2.4.0",
"gulp": "git://github.com/gulpjs/gulp#4.0",
"gulp-babel": "^5",
@ -96,6 +95,7 @@
"gulp-sourcemaps": "^1.5.1",
"gulp-watch": "^4.2.2",
"mocha": "^2.2.1",
"must": "^0.12.0",
"node-inspector": "^0.10.1",
"sinon": "^1.14.1",
"standard": "^4.0.0"
@ -106,7 +106,7 @@
"lint": "standard",
"prepublish": "npm run build",
"start": "node bin/xo-server",
"test": "npm run lint && dependency-check ./package.json && mocha --opts .mocha.opts 'dist/**/*.spec.js'"
"test": "npm run lint && dependency-check ./package.json && mocha --opts .mocha.opts \"dist/**/*.spec.js\""
},
"standard": {
"ignore": [

View File

@ -1,7 +1,3 @@
import {Unauthorized} from '../api-errors'
// ===================================================================
// TODO: Prevent token connections from creating tokens.
// TODO: Token permission.
export async function create () {

View File

@ -1,6 +1,6 @@
/* eslint-env mocha */
import {expect} from 'chai'
import expect from 'must'
// ===================================================================

View File

@ -447,10 +447,18 @@ export default async function main (args) {
info('Default user created:', email, ' with password', password)
}
// Handle gracefully shutdown.
const closeWebServer = () => { webServer.close() }
process.on('SIGINT', closeWebServer)
process.on('SIGTERM', closeWebServer)
// Gracefully shutdown on signals.
//
// TODO: implements a timeout? (or maybe it is the services launcher
// responsability?)
process.on('SIGINT', () => {
debug('SIGINT caught, closing web server…')
webServer.close()
})
process.on('SIGTERM', () => {
debug('SIGTERM caught, closing web server…')
webServer.close()
})
return eventToPromise(webServer, 'close')
}

View File

@ -1,6 +1,6 @@
/* eslint-env mocha */
import {expect} from 'chai'
import expect from 'must'
// ===================================================================
@ -12,6 +12,12 @@ import {
// ===================================================================
describe('ensureArray', function () {
it('wrap the value in an array', function () {
const value = 'foo'
expect(ensureArray(value)).to.eql([value])
})
it('returns an empty array for undefined', function () {
expect(ensureArray(undefined)).to.eql([])
})
@ -21,12 +27,6 @@ describe('ensureArray', function () {
expect(ensureArray(array)).to.equal(array)
})
it('wrap the value in an object', function () {
const value = {}
expect(ensureArray(value)).to.includes(value)
})
})
// -------------------------------------------------------------------

View File

@ -7,7 +7,10 @@ import map from 'lodash.map'
import unzip from 'julien-f-unzip'
import {PassThrough} from 'stream'
import {promisify} from 'bluebird'
import {Xapi as XapiBase} from 'xen-api'
import {
wrapError as wrapXapiError,
Xapi as XapiBase
} from 'xen-api'
import {debounce} from './decorators'
import {ensureArray, noop, parseXml, pFinally} from './utils'
@ -19,13 +22,6 @@ const debug = createDebug('xo:xapi')
const gotPromise = promisify(got)
const wrapError = error => {
const e = new Error(error[0])
e.code = error[0]
e.params = error.slice(1)
return e
}
// ===================================================================
const typeToNamespace = Object.create(null)
@ -107,7 +103,7 @@ export default class Xapi extends XapiBase {
if (status === 'success') {
taskWatchers[ref].resolve(object.result)
} else if (status === 'failure') {
taskWatchers[ref].reject(wrapError(object.error_info))
taskWatchers[ref].reject(wrapXapiError(object.error_info))
} else {
return
}