1
0
Fork 0

arangosh now uses config file name corresponding to binary name

This commit is contained in:
Frank Celler 2013-12-20 23:49:16 +01:00
parent 4efb291420
commit 1ef596733d
9 changed files with 120 additions and 41 deletions

View File

@ -1,6 +1,9 @@
v1.4.x (XXXX-XX-XX)
-------------------
* arangosh now uses the config-file which maps the binary name, i. e. if you
rename arangosh to foxx-manager it will use the config file foxx-manager.conf
* fixed issue #711, #687: foxx-manager throws internal errors
* added `--server.ssl-protocol` option for client tools

View File

@ -1141,11 +1141,11 @@ BUILT_SOURCES = build.h etc/arangodb/arangod-uid.conf \
etc/arangodb/arangod.conf etc/arangodb/arangodump.conf \
etc/arangodb/arangoimp.conf etc/arangodb/arangoirb.conf \
etc/arangodb/arangorestore.conf etc/arangodb/arangosh.conf \
$(am__append_12) Doxygen/.setup-directories \
$(JAVASCRIPT_BROWSER) @builddir@/.setup-js-directories \
$(am__append_13) $(am__append_15) $(am__append_16) @ZLIB_LIBS@ \
$(am__append_17) $(am__append_19) $(am__append_21) \
$(am__append_23)
etc/arangodb/foxx-manager.conf $(am__append_12) \
Doxygen/.setup-directories $(JAVASCRIPT_BROWSER) \
@builddir@/.setup-js-directories $(am__append_13) \
$(am__append_15) $(am__append_16) @ZLIB_LIBS@ $(am__append_17) \
$(am__append_19) $(am__append_21) $(am__append_23)
################################################################################
### @brief man pages to install

14
README
View File

@ -1,8 +1,8 @@
ArangoDB
ArangoDB is a multi-purpose open-source database with flexible data models for
documents, graphs, and key-values. Build high performance application using a
convenient sql-like query language or JavaScript/Ruby extensions.
documents, graphs, and key-values. Build high performance applications using a
convenient SQL-like query language or JavaScript/Ruby extensions.
Key features include:
* Schema-free schemata let you combine the space efficiency of MySQL with the
@ -21,7 +21,7 @@ Key features include:
* No-nonsense storage: ArangoDB uses all of the power of modern storage
hardware, like SSD and large caches
* Powerful query language (AQL) to retrieve data
* Transactions: run queries on multiple documents or collections with optional
* Transactions: run queries on multiple documents or collections with optional
transactional consistency and isolation
* Replication: set up the database in a master-slave configuration
* It is open source (Apache Licence 2.0)
@ -87,3 +87,11 @@ You can use the Google group for improvements, feature requests, comments
http://www.arangodb.org/connect
Citing ArangoDB
Please kindly cite ArangoDB in your publications if it helps your research:
bibtex @misc{ArangoDB2013, Author = {ArangoDB}, Title = { {ArangoDB}: An Open
Source multi-purpose database supporting flexible data models for documents,
graphs, and key-values.}, Year = {2013}, Howpublished = {\url{http://
arangodb.org/} }

View File

@ -72,6 +72,20 @@ using namespace triagens::arango;
// --SECTION-- private variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief Windows console codepage
////////////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
static int CodePage = 65001;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief command prompt
////////////////////////////////////////////////////////////////////////////////
static string Prompt = "arangosh [%d]> ";
////////////////////////////////////////////////////////////////////////////////
/// @brief base class for clients
////////////////////////////////////////////////////////////////////////////////
@ -84,14 +98,6 @@ ArangoClient BaseClient;
V8ClientConnection* ClientConnection = 0;
////////////////////////////////////////////////////////////////////////////////
/// @brief Windows console codepage
////////////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
static int CodePage = 65001;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief object template for the initial connection
////////////////////////////////////////////////////////////////////////////////
@ -158,12 +164,6 @@ static vector<string> UnitTests;
static vector<string> JsLint;
////////////////////////////////////////////////////////////////////////////////
/// @brief command prompt
////////////////////////////////////////////////////////////////////////////////
static string Prompt = "arangosh [%d]> ";
// -----------------------------------------------------------------------------
// --SECTION-- JavaScript functions
// -----------------------------------------------------------------------------
@ -358,7 +358,7 @@ static v8::Handle<v8::Value> JS_ImportJsonFile (v8::Arguments const& argv) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief normalize UTF 16 strings
/// @brief normalizes UTF 16 strings
////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_normalize_string (v8::Arguments const& argv) {
@ -391,24 +391,18 @@ static v8::Handle<v8::Value> JS_compare_string (v8::Arguments const& argv) {
}
// -----------------------------------------------------------------------------
// --SECTION-- private functions
// --SECTION-- private enums
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief return a new client connection instance
/// @brief ClientConnection class
////////////////////////////////////////////////////////////////////////////////
static V8ClientConnection* CreateConnection () {
return new V8ClientConnection(BaseClient.endpointServer(),
BaseClient.databaseName(),
BaseClient.username(),
BaseClient.password(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
ArangoClient::DEFAULT_RETRIES,
BaseClient.sslProtocol(),
false);
}
enum WRAP_CLASS_TYPES {WRAP_TYPE_CONNECTION = 1};
// -----------------------------------------------------------------------------
// --SECTION-- private functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief parses the program options
@ -462,7 +456,13 @@ static vector<string> ParseProgramOptions (int argc, char* argv[]) {
// and parse the command line and config file
ProgramOptions options;
BaseClient.parse(options, description, argc, argv, "arangosh.conf");
char* p = TRI_BinaryName(argv[0]);
string conf = p;
TRI_FreeString(TRI_CORE_MEM_ZONE, p);
conf += ".conf";
BaseClient.parse(options, description, argc, argv, conf);
// set V8 options
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
@ -487,13 +487,15 @@ static vector<string> ParseProgramOptions (int argc, char* argv[]) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief copy v8::Object to std::map<string, string>
/// @brief copies v8::Object to std::map<string, string>
////////////////////////////////////////////////////////////////////////////////
static void objectToMap (map<string, string>& myMap, v8::Handle<v8::Value> val) {
v8::Handle<v8::Object> v8Headers = val.As<v8::Object> ();
if (v8Headers->IsObject()) {
v8::Handle<v8::Array> props = v8Headers->GetPropertyNames();
for (uint32_t i = 0; i < props->Length(); i++) {
v8::Handle<v8::Value> key = props->Get(v8::Integer::New(i));
myMap[TRI_ObjectToString(key)] = TRI_ObjectToString(v8Headers->Get(key));
@ -502,10 +504,20 @@ static void objectToMap (map<string, string>& myMap, v8::Handle<v8::Value> val)
}
////////////////////////////////////////////////////////////////////////////////
/// @brief ClientConnection class
/// @brief returns a new client connection instance
////////////////////////////////////////////////////////////////////////////////
enum WRAP_CLASS_TYPES {WRAP_TYPE_CONNECTION = 1};
static V8ClientConnection* CreateConnection () {
return new V8ClientConnection(BaseClient.endpointServer(),
BaseClient.databaseName(),
BaseClient.username(),
BaseClient.password(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
ArangoClient::DEFAULT_RETRIES,
BaseClient.sslProtocol(),
false);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief weak reference callback for queries (call the destructor here)
@ -1569,6 +1581,8 @@ static void arangoshExitFunction (int, void*);
// .............................................................................
// Call this function to do various initialistions for windows only
//
// TODO can we move this to a general function for all binaries?
// .............................................................................
void arangoshEntryFunction() {
@ -1798,6 +1812,8 @@ int main (int argc, char* argv[]) {
if (CodePage > 0) {
SetConsoleOutputCP((UINT) CodePage);
}
// TODO we should have a special "printf" which can handle the color escape sequences!
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
printf(" ");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);

View File

@ -11,7 +11,8 @@ BUILT_SOURCES += \
etc/arangodb/arangoimp.conf \
etc/arangodb/arangoirb.conf \
etc/arangodb/arangorestore.conf \
etc/arangodb/arangosh.conf
etc/arangodb/arangosh.conf \
etc/arangodb/foxx-manager.conf
################################################################################
### @brief config

View File

@ -0,0 +1,11 @@
pretty-print = true
[server]
endpoint = tcp://localhost:8529
disable-authentication = true
[javascript]
startup-directory = @PKGDATADIR@/js
modules-path = @PKGDATADIR@/js/client/modules;@PKGDATADIR@/js/common/modules;@PKGDATADIR@/js/node
package-path = @PKGDATADIR@/js/npm
execute-string = require("org/arangodb/foxx/manager").run(ARGUMENTS);

View File

@ -0,0 +1,10 @@
pretty-print = true
[server]
disable-authentication = true
[javascript]
startup-directory = ./js
modules-path = ./js/client/modules;./js/common/modules;./js/node
package-path = ./js/npm
execute-string = require("org/arangodb/foxx/manager").run(ARGUMENTS);

View File

@ -1578,6 +1578,30 @@ char* TRI_GetAbsolutePath (char const* file, char const* cwd) {
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the binary name without any path or suffix
////////////////////////////////////////////////////////////////////////////////
char* TRI_BinaryName (const char* argv0) {
char* name;
char* p;
char* e;
name = TRI_Basename(argv0);
p = name;
e = name + strlen(name);
for (; p < e; ++p) {
if (*p == '.') {
*p = '\0';
break;
}
}
return name;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief locates the directory containing the program
////////////////////////////////////////////////////////////////////////////////

View File

@ -246,6 +246,12 @@ char* TRI_GetFilename (char const*);
char* TRI_GetAbsolutePath (char const*, char const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the binary name without any path or suffix
////////////////////////////////////////////////////////////////////////////////
char* TRI_BinaryName (const char* argv0);
////////////////////////////////////////////////////////////////////////////////
/// @brief locates the directory containing the program
////////////////////////////////////////////////////////////////////////////////