CLI is now installable via npm & testable.
This commit is contained in:
7
bin/xo-server
Executable file
7
bin/xo-server
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
//====================================================================
|
||||
|
||||
require('exec-promise')(require('../'));
|
||||
6
index.js
Normal file
6
index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
//====================================================================
|
||||
|
||||
require('coffee-script/register');
|
||||
module.exports = require('./src/main');
|
||||
33
package.json
33
package.json
@@ -1,22 +1,34 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Julien Fontanet",
|
||||
"email": "julien.fontanet@vates.fr",
|
||||
"url": "http://vates.fr/"
|
||||
},
|
||||
"name": "XO-Server",
|
||||
"name": "xo-server",
|
||||
"version": "3.4.0",
|
||||
"license": "AGPL3",
|
||||
"description": "XO-Server is part of Xen-Orchestra, a web interface for XenServer or XAPI enabled hosts.",
|
||||
"keywords": [
|
||||
"xen",
|
||||
"orchestra",
|
||||
"xen-orchestra",
|
||||
"server"
|
||||
],
|
||||
"homepage": "http://github.com/vatesfr/xo-server/",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vatesfr/xo-server/issues"
|
||||
},
|
||||
"author": "Julien Fontanet <julien.fontanet@vates.fr>",
|
||||
"preferGlobal": true,
|
||||
"directories": {
|
||||
"bin": "bin"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/vatesfr/xo-server.git"
|
||||
},
|
||||
"main": "src/main.coffee",
|
||||
"dependencies": {
|
||||
"backoff": "~2.3.0",
|
||||
"bluebird": "^1.2.4",
|
||||
"coffee-script": "~1.7.1",
|
||||
"connect": "^2.17.1",
|
||||
"event-to-promise": "^0.2.4",
|
||||
"exec-promise": "^0.2.4",
|
||||
"extendable": "~0.0.6",
|
||||
"fibers": "~1.0.1",
|
||||
"hashy": "~0.3.5",
|
||||
@@ -40,12 +52,7 @@
|
||||
"node-inspector": "^0.7.3",
|
||||
"sinon": "^1.10.0"
|
||||
},
|
||||
"description": "XO-Server is part of Xen-Orchestra, a web interface for XenServer or XAPI enabled hosts.",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vatesfr/xo-server/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./run-tests"
|
||||
},
|
||||
"license": "AGPL3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,8 +73,6 @@ $fiberize = (fn) ->
|
||||
).run()
|
||||
|
||||
# Makes a function run in its own fiber and returns a promise.
|
||||
#
|
||||
# TODO: should we keep it?
|
||||
$promisify = (fn) ->
|
||||
(args...) ->
|
||||
new $Promise (resolve, reject) ->
|
||||
|
||||
@@ -9,6 +9,8 @@ $_ = require 'underscore'
|
||||
# HTTP(s) middleware framework.
|
||||
$connect = require 'connect'
|
||||
|
||||
$eventToPromise = require 'event-to-promise'
|
||||
|
||||
# Configuration handling.
|
||||
$nconf = require 'nconf'
|
||||
|
||||
@@ -28,7 +30,7 @@ $Connection = require './connection'
|
||||
$XO = require './xo'
|
||||
|
||||
# Helpers for dealing with fibers.
|
||||
{$fiberize, $waitEvent, $wait} = require './fibers-utils'
|
||||
{$fiberize, $promisify, $waitEvent, $wait} = require './fibers-utils'
|
||||
|
||||
# HTTP/HTTPS server which can listen on multiple ports.
|
||||
$WebServer = require 'http-server-plus'
|
||||
@@ -86,7 +88,11 @@ $handleJsonRpcCall = (api, session, encodedRequest) ->
|
||||
#=====================================================================
|
||||
|
||||
# Main.
|
||||
do $fiberize ->
|
||||
module.exports = $promisify (args) ->
|
||||
|
||||
# Relative paths in the configuration are relative to this
|
||||
# directory's parent.
|
||||
process.chdir "#{__dirname}/.."
|
||||
|
||||
# Loads the environment.
|
||||
$nconf.env()
|
||||
@@ -219,3 +225,5 @@ do $fiberize ->
|
||||
password = 'admin' # TODO: Should be generated.
|
||||
xo.users.create email, password, 'admin'
|
||||
console.log "[INFO] Default user: “#{email}” with password “#{password}”"
|
||||
|
||||
return $eventToPromise webServer, 'close'
|
||||
|
||||
46
xo-server
46
xo-server
@@ -1,46 +0,0 @@
|
||||
#/bin/sh -eu
|
||||
|
||||
# This file is a part of Xen Orchestra Server.
|
||||
#
|
||||
# Xen Orchestra Server is free software: you can redistribute it
|
||||
# and/or modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation, either version 3 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# Xen Orchestra Server is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Xen Orchestra Server. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
# @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
#
|
||||
# @package Xen Orchestra Server
|
||||
|
||||
MAIN='src/main.coffee'
|
||||
|
||||
COFFEE='./node_modules/.bin/coffee'
|
||||
|
||||
#######################################
|
||||
|
||||
cd -P "$(dirname "$(which "$0")")"
|
||||
|
||||
########################################
|
||||
|
||||
if [ "${1:-}" = '--debug' ]
|
||||
then
|
||||
shift
|
||||
|
||||
# Launch XO-Server in debug mode.
|
||||
"$COFFEE" --nodejs --debug-brk "$MAIN" "$@" > /dev/null &
|
||||
|
||||
# Runs Node Inspector (avoids the recommended alternate HTTP port
|
||||
# for XO-Server).
|
||||
exec ./node_modules/.bin/node-inspector --web-port 64985
|
||||
else
|
||||
exec "$COFFEE" "$MAIN" "$@"
|
||||
fi
|
||||
Reference in New Issue
Block a user