mirror of https://gitee.com/bigwinds/arangodb
more documentation, separate modules.js for server
This commit is contained in:
parent
558845eb1b
commit
323c266273
|
@ -52,20 +52,20 @@ namespace triagens {
|
|||
ApplicationServerImpl::ApplicationServerImpl (string const& title, string const& version)
|
||||
: title(title),
|
||||
version(version),
|
||||
initFile(""),
|
||||
userConfigFile(""),
|
||||
systemConfigFile(""),
|
||||
uid(""),
|
||||
gid(""),
|
||||
initFile(),
|
||||
userConfigFile(),
|
||||
systemConfigFile(),
|
||||
uid(),
|
||||
gid(),
|
||||
logApplicationName("triagens"),
|
||||
logHostName("-"),
|
||||
logFacility("-"),
|
||||
logLevel("info"),
|
||||
logFormat(""),
|
||||
logFormat(),
|
||||
logSeverity("all"),
|
||||
logFile("+"),
|
||||
logPrefix(""),
|
||||
logSyslog(""),
|
||||
logPrefix(),
|
||||
logSyslog(),
|
||||
logThreadId(false),
|
||||
logLineNumber(false),
|
||||
randomGenerator(3) {
|
||||
|
|
|
@ -403,7 +403,7 @@ static size_t GenerateMessage (char* buffer,
|
|||
|
||||
TRI_LockSpin(&OutputPrefixLock);
|
||||
|
||||
if (OutputPrefix) {
|
||||
if (OutputPrefix && *OutputPrefix) {
|
||||
n = snprintf(buffer + m, size - m, "%s %s ", s, OutputPrefix);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
|
|||
|
||||
AM_CFLAGS =
|
||||
AM_CXXFLAGS =
|
||||
AM_CPPFLAGS = -D_SYSCONFDIR_='"${sysconfdir}"' -D_PKGDATADIR_='"${pkgdatadir}"'
|
||||
AM_CPPFLAGS = -D_SYSCONFDIR_='"${sysconfdir}"' -D_PKGDATADIR_='"${pkgdatadir}"' -D_DATABASEDIR_='"${localstatedir}/lib/${PACKAGE_TARNAME}"'
|
||||
AM_LDFLAGS =
|
||||
BUILT_SOURCES = .setup-directories
|
||||
LIBS =
|
||||
|
@ -12,6 +12,7 @@ bin_PROGRAMS = avocado
|
|||
|
||||
nobase_pkgdata_DATA = \
|
||||
$(shell find @srcdir@/js/system -name "*.js" -print) \
|
||||
$(shell find @srcdir@/js/modules -name "*.js" -print) \
|
||||
$(shell find @srcdir@/html -name "*.css" -print) \
|
||||
$(shell find @srcdir@/html -name "*.gif" -print) \
|
||||
$(shell find @srcdir@/html -name "*.html" -print) \
|
||||
|
|
|
@ -231,6 +231,7 @@ avocado_SOURCES = \
|
|||
BUILT_SOURCES += \
|
||||
js/bootstrap/js-modules.h \
|
||||
js/bootstrap/js-print.h \
|
||||
js/server/js-modules.h \
|
||||
js/server/js-actions.h \
|
||||
js/server/js-aql.h \
|
||||
js/server/js-json.h \
|
||||
|
@ -274,6 +275,7 @@ DOXYGEN = \
|
|||
Doxygen/js/bootstrap/modules.c \
|
||||
Doxygen/js/modules/graph.c \
|
||||
Doxygen/js/modules/jsunity.c \
|
||||
Doxygen/js/server/modules.c \
|
||||
Doxygen/js/server/actions.c \
|
||||
Doxygen/js/server/json.c \
|
||||
Doxygen/js/server/shell.c \
|
||||
|
@ -313,7 +315,11 @@ WIKI = \
|
|||
Doxygen/xml/dc/d05/UserManual.md \
|
||||
Doxygen/xml/d3/d5b/jsUnity.md \
|
||||
Doxygen/xml/da/db6/InstallManual.md \
|
||||
Doxygen/xml/dd/dd7/RefManual.md
|
||||
Doxygen/xml/dd/dd7/RefManual.md \
|
||||
Doxygen/xml/d8/d3a/Basics.md
|
||||
|
||||
Doxygen/xml/d8/d3a/Basics.md: Doxygen/xml/d8/d3a/Basics.xml
|
||||
python @top_srcdir@/Doxygen/Scripts/xml2md.py $< > $@
|
||||
|
||||
Doxygen/xml/da/db6/InstallManual.md: Doxygen/xml/da/db6/InstallManual.xml
|
||||
python @top_srcdir@/Doxygen/Scripts/xml2md.py $< > $@
|
||||
|
|
|
@ -230,10 +230,10 @@ void ActionDisptacherThread::initialise () {
|
|||
bool ok;
|
||||
char const* files[] = { "bootstrap/modules.js",
|
||||
"bootstrap/print.js",
|
||||
"server/modules.js",
|
||||
"server/json.js",
|
||||
"server/actions.js",
|
||||
"server/aql.js",
|
||||
"server/shell.js"
|
||||
"server/aql.js"
|
||||
};
|
||||
size_t i;
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ using namespace triagens::avocado;
|
|||
|
||||
#include "js/bootstrap/js-print.h"
|
||||
#include "js/bootstrap/js-modules.h"
|
||||
#include "js/server/js-modules.h"
|
||||
#include "js/server/js-actions.h"
|
||||
#include "js/server/js-aql.h"
|
||||
#include "js/server/js-json.h"
|
||||
|
@ -171,6 +172,11 @@ AvocadoServer::AvocadoServer (int argc, char** argv)
|
|||
|
||||
#ifdef _PKGDATADIR_
|
||||
_systemActionPath = string(_PKGDATADIR_) + "/js/system";
|
||||
_startupModules = string(_PKGDATADIR_) + "/js/modules";
|
||||
#endif
|
||||
|
||||
#ifdef _DATABASEDIR_
|
||||
_databasePath = _DATABASEDIR_;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -244,7 +250,6 @@ void AvocadoServer::buildApplicationServer () {
|
|||
|
||||
additional["PORT Options"]
|
||||
("server.http-port", &_httpPort, "port for client access")
|
||||
("dispatcher.threads", &_dispatcherThreads, "number of dispatcher threads")
|
||||
;
|
||||
|
||||
additional[ApplicationServer::OPTIONS_HIDDEN]
|
||||
|
@ -263,7 +268,7 @@ void AvocadoServer::buildApplicationServer () {
|
|||
// JavaScript options
|
||||
// .............................................................................
|
||||
|
||||
additional["JAVASCRIPT Options"]
|
||||
additional["JAVASCRIPT Options:help-admin"]
|
||||
("startup.directory", &_startupPath, "path to the directory containing alternate startup scripts")
|
||||
("startup.modules-path", &_startupModules, "one or more directories separated by semicolon")
|
||||
("action.directory", &_actionPath, "path to the action directory, defaults to <database.directory>/_ACTIONS")
|
||||
|
@ -280,6 +285,7 @@ void AvocadoServer::buildApplicationServer () {
|
|||
|
||||
additional["Server Options:help-admin"]
|
||||
("server.admin-port", &_adminPort, "http server:port for ADMIN requests")
|
||||
("dispatcher.threads", &_dispatcherThreads, "number of dispatcher threads")
|
||||
;
|
||||
|
||||
// .............................................................................
|
||||
|
@ -308,6 +314,7 @@ void AvocadoServer::buildApplicationServer () {
|
|||
LOGGER_INFO << "using built-in JavaScript startup files";
|
||||
StartupLoader.defineScript("bootstrap/modules.js", JS_bootstrap_modules);
|
||||
StartupLoader.defineScript("bootstrap/print.js", JS_bootstrap_print);
|
||||
StartupLoader.defineScript("server/modules.js", JS_server_modules);
|
||||
StartupLoader.defineScript("server/actions.js", JS_server_actions);
|
||||
StartupLoader.defineScript("server/aql.js", JS_server_aql);
|
||||
StartupLoader.defineScript("server/json.js", JS_server_json);
|
||||
|
@ -413,9 +420,12 @@ int AvocadoServer::startupServer () {
|
|||
// create the action dispatcher thread infor
|
||||
// .............................................................................
|
||||
|
||||
LOGGER_INFO << "using JavaScript modules path '" << _startupModules << "'";
|
||||
|
||||
ActionDisptacherThread::_actionLoader = &ActionLoader;
|
||||
ActionDisptacherThread::_startupLoader = &StartupLoader;
|
||||
ActionDisptacherThread::_vocbase = _vocbase;
|
||||
ActionDisptacherThread::_startupModules = _startupModules;
|
||||
|
||||
SystemActionDisptacherThread::_actionLoader = &SystemActionLoader;
|
||||
|
||||
|
@ -538,6 +548,7 @@ void AvocadoServer::executeShell () {
|
|||
bool ok;
|
||||
char const* files[] = { "bootstrap/modules.js",
|
||||
"bootstrap/print.js",
|
||||
"server/modules.js",
|
||||
"server/json.js",
|
||||
"server/aql.js",
|
||||
"server/shell.js"
|
||||
|
@ -570,6 +581,8 @@ void AvocadoServer::executeShell () {
|
|||
|
||||
context->Enter();
|
||||
|
||||
LOGGER_INFO << "using JavaScript modules path '" << _startupModules << "'";
|
||||
|
||||
TRI_InitV8VocBridge(context, _vocbase);
|
||||
TRI_InitV8Conversions(context);
|
||||
TRI_InitV8Utils(context, _startupModules);
|
||||
|
|
|
@ -35,22 +35,32 @@ using namespace triagens::basics;
|
|||
using namespace triagens::rest;
|
||||
using namespace triagens::avocado;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- USER MANUAL
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page UserManual AvocadoDB User Manual
|
||||
///
|
||||
/// <ol>
|
||||
/// <li>Basics
|
||||
/// <li>@ref Basics
|
||||
/// <ol>
|
||||
/// <li>@ref StartStop
|
||||
/// </li>
|
||||
/// <li>@ref AvocadoScript
|
||||
/// <ol>
|
||||
/// <li>@ref GeoCoordinates
|
||||
/// </li>
|
||||
/// <li>@ref Pagination
|
||||
/// </li>
|
||||
/// </ol>
|
||||
/// </li>
|
||||
/// <li>@ref HttpInterface
|
||||
/// <ol>
|
||||
/// <li>@ref RestInterface
|
||||
/// </li>
|
||||
/// <ol>
|
||||
/// <li>@ref RestDocument
|
||||
/// </li>
|
||||
/// </ol>
|
||||
/// <li>@ref RestDocument
|
||||
/// </li>
|
||||
/// </ol>
|
||||
/// </li>
|
||||
/// <li>Vertices, Edges, and Graphs
|
||||
|
@ -86,6 +96,91 @@ using namespace triagens::avocado;
|
|||
/// </ol>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page Basics Basics
|
||||
///
|
||||
/// The AvocadoDB groups documents into collections. Each collection can be
|
||||
/// accessed using queries. For simple queries involving just one collection,
|
||||
/// you can use a fluent interface from within JavaScript code, see @ref
|
||||
/// AvocadoScript. This interface allows you to select documents from one
|
||||
/// collection based on simple search criteria. The @ref HttpInterface
|
||||
/// lets you create, modify, or delete a single document via HTTP. For
|
||||
/// more complex queries, you can use the Avocado Query Language, which is
|
||||
/// an extension of SQL resp. UNQL.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page StartStopTOC
|
||||
///
|
||||
/// <ol>
|
||||
/// <li>@ref StartStopHttp "Starting the HTTP Server"</li>
|
||||
/// <li>@ref StartStopDebug "Starting the Debug Shell"</li>
|
||||
/// <li>@ref StartStopOptions "Frequently Used Options"</li>
|
||||
/// </ol>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page StartStop Starting the AvocadoDB
|
||||
///
|
||||
/// The AvocadoDB has two mode of operation: as server, where it will answer to
|
||||
/// HTTP requests, see @ref HttpInterface, and a debug shell, where you can
|
||||
/// access the database directly. Using the debug shell allows you to issue all
|
||||
/// commands normally available in actions and transactions, see @ref
|
||||
/// AvocadoScript.
|
||||
///
|
||||
/// You should never start more than one server for the same database,
|
||||
/// independent from the mode of operation.
|
||||
///
|
||||
/// <hr>
|
||||
/// @copydoc StartStopTOC
|
||||
/// <hr>
|
||||
///
|
||||
/// @section StartStopHttp Starting the HTTP Server
|
||||
///
|
||||
/// The following command starts the AvocadoDB in server mode. You will be able
|
||||
/// to access the server using HTTP request on port 8529. See below for a list
|
||||
/// of frequently used options, see @ref CommandLine "here" for a complete list.
|
||||
///
|
||||
/// @verbinclude start2
|
||||
///
|
||||
/// @section StartStopDebug Starting the Debug Shell
|
||||
///
|
||||
/// The following command starts a debug shell. See below for a list of
|
||||
/// frequently used options, see @ref CommandLine "here" for a complete list.
|
||||
///
|
||||
/// @verbinclude start1
|
||||
///
|
||||
/// @section StartStopOptions Frequently Used Options
|
||||
///
|
||||
/// The following command-line options are frequently used. For a full
|
||||
/// list of options see @ref CommandLine "here".
|
||||
///
|
||||
/// @CMDOPT{@CA{database-directory}}
|
||||
///
|
||||
/// Uses the @CA{database-directory} as base directory. There is an alternative
|
||||
/// version available for use in configuration files, see @ref
|
||||
/// CommandLineAvocado "here".
|
||||
///
|
||||
/// @copydetails triagens::rest::ApplicationServerImpl::options
|
||||
///
|
||||
/// @CMDOPT{--log @CA{level}}
|
||||
///
|
||||
/// Allows the user to choose the level of information which is logged by the
|
||||
/// server. The @CA{level} is specified as a string and can be one of the
|
||||
/// following values: fatal, error, warning, info, debug, trace. For more
|
||||
/// information see @ref CommandLineLogging "here".
|
||||
///
|
||||
/// @copydetails triagens::avocado::AvocadoServer::_httpPort
|
||||
///
|
||||
/// @CMDOPT{--shell}
|
||||
///
|
||||
/// Opens a debug shell instead of starting the HTTP server.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- INSTALLATION MANUAL
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page InstallManual AvocadoDB Installation Manual
|
||||
///
|
||||
|
@ -99,6 +194,10 @@ using namespace triagens::avocado;
|
|||
/// </ol>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- REFERENCE MANUAL
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page RefManual AvocadoDB Reference Manual
|
||||
///
|
||||
|
@ -129,74 +228,6 @@ using namespace triagens::avocado;
|
|||
/// </ol>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page StartStopTOC
|
||||
///
|
||||
/// <ol>
|
||||
/// <li>@ref StartStopDebug "Starting the Debug Shell"</li>
|
||||
/// <li>@ref StartStopHttp "Starting the HTTP Server"</li>
|
||||
/// <li>@ref StartStopOptions "Frequently Used Options"</li>
|
||||
/// </ol>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page StartStop Starting the AvocadoDB
|
||||
///
|
||||
/// The AvocadoDB has two mode of operation: as server, where it will answer to
|
||||
/// HTTP requests, see @ref HttpInterface, and a debug shell, where you can
|
||||
/// access the database directly. Using the debug shell allows you to issue all
|
||||
/// commands normally available in actions and transactions, see @ref
|
||||
/// AvocadoScript.
|
||||
///
|
||||
/// You should never start more than one server for the same database,
|
||||
/// independent from the mode of operation.
|
||||
///
|
||||
/// <hr>
|
||||
/// @copydoc StartStopTOC
|
||||
/// <hr>
|
||||
///
|
||||
/// @section StartStopDebug Starting the Debug Shell
|
||||
///
|
||||
/// The following command starts a debug shell. See below for a list of
|
||||
/// frequently used options, see @ref CommandLine "here" for a complete list.
|
||||
///
|
||||
/// @verbinclude start1
|
||||
///
|
||||
/// @section StartStopHttp Starting the HTTP Server
|
||||
///
|
||||
/// The following command starts the AvocadoDB in server mode. You will be able
|
||||
/// to access the server using HTTP request on port 8529. See below for a list
|
||||
/// of frequently used options, see @ref CommandLine "here" for a complete list.
|
||||
///
|
||||
/// @verbinclude start2
|
||||
///
|
||||
/// @section StartStopOptions Frequently Used Options
|
||||
///
|
||||
/// The following command-line options are frequently used. For a full
|
||||
/// list of options see @ref CommandLine "here".
|
||||
///
|
||||
/// @CMDOPT{@CA{database-directory}}
|
||||
///
|
||||
/// Uses the @CA{database-directory} as base directory. There is an alternative
|
||||
/// version available for use in configuration files, see @ref
|
||||
/// CommandLineAvocado "here".
|
||||
///
|
||||
/// @copydetails triagens::rest::ApplicationServerImpl::options
|
||||
///
|
||||
/// @CMDOPT{--log @CA{level}}
|
||||
///
|
||||
/// Allows the user to choose the level of information which is logged by the
|
||||
/// server. The @CA{level} is specified as a string and can be one of the
|
||||
/// following values: fatal, error, warning, info, debug, trace. For more
|
||||
/// information see @ref CommandLineLogging "here".
|
||||
///
|
||||
/// @copydetails triagens::avocado::AvocadoServer::_httpPort
|
||||
///
|
||||
/// @CMDOPT{--shell}
|
||||
///
|
||||
/// Opens a debug shell instead of starting the HTTP server.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page CommandLineTOC
|
||||
///
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
#include "V8/v8-globals.h"
|
||||
#include "ShapedJson/shaped-json.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- documentation
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page AvocadoScript Avocado Script
|
||||
///
|
||||
|
@ -43,7 +47,6 @@
|
|||
/// - selection by example
|
||||
/// - field selection (aka projection)
|
||||
/// - sorting
|
||||
/// - cursors
|
||||
/// - pagination of the result-set
|
||||
///
|
||||
/// Advanced topics are
|
||||
|
@ -106,9 +109,12 @@
|
|||
///
|
||||
/// Next steps:
|
||||
///
|
||||
/// - learn about @ref GeoCoordinates "geo coordinates"
|
||||
/// - learn about @ref Pagination "pagination"
|
||||
/// - look at all the @ref JavaScriptFunc "functions"
|
||||
/// - learn about @ref SelectionByExample
|
||||
/// - learn about @ref FieldSelection
|
||||
/// - learn about @ref Sorting
|
||||
/// - learn about @ref Pagination
|
||||
/// - learn about @ref GeoCoordinates
|
||||
/// - look at all the @ref JavaScriptFunc
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
2
build.h
2
build.h
|
@ -1 +1 @@
|
|||
#define TRIAGENS_VERSION "0.0.8 [1316:1317M]"
|
||||
#define TRIAGENS_VERSION "0.0.8 [1320:1321M]"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
defineAction("near",
|
||||
function (req, res) {
|
||||
var result = req.collection.near(req.lat, req.lon).distance();
|
||||
var result = req.collection.near(req.lat, req.lon).distance();
|
||||
|
||||
queryResult(req, res, result);
|
||||
},
|
||||
|
@ -15,7 +15,7 @@ defineAction("near",
|
|||
|
||||
defineAction("within",
|
||||
function (req, res) {
|
||||
var result = req.collection.within(req.lat, req.lon, req.radius).distance();
|
||||
var result = req.collection.within(req.lat, req.lon, req.radius).distance();
|
||||
|
||||
queryResult(req, res, result);
|
||||
},
|
||||
|
|
|
@ -25,6 +25,13 @@
|
|||
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page FluentInterface Fluent Interface
|
||||
///
|
||||
/// The fluent interface for queries allows you to build simple queries
|
||||
/// involving just one collection in a very natural way.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- FLUENT QUERY
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
var internal = require("internal");
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- AvocadoFluentQuery
|
||||
// --SECTION-- PRINT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue