Skip to content

Commit

Permalink
arangosh now uses config file name corresponding to binary name
Browse files Browse the repository at this point in the history
  • Loading branch information
fceller committed Dec 20, 2013
1 parent 4efb291 commit 1ef5967
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 41 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions README
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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/} }
80 changes: 48 additions & 32 deletions arangosh/V8Client/arangosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,30 @@ using namespace triagens::arango;
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief base class for clients
/// @brief Windows console codepage
////////////////////////////////////////////////////////////////////////////////

ArangoClient BaseClient;
#ifdef _WIN32
static int CodePage = 65001;
#endif

////////////////////////////////////////////////////////////////////////////////
/// @brief the initial default connection
/// @brief command prompt
////////////////////////////////////////////////////////////////////////////////

V8ClientConnection* ClientConnection = 0;
static string Prompt = "arangosh [%d]> ";

////////////////////////////////////////////////////////////////////////////////
/// @brief Windows console codepage
/// @brief base class for clients
////////////////////////////////////////////////////////////////////////////////

#ifdef _WIN32
static int CodePage = 65001;
#endif
ArangoClient BaseClient;

////////////////////////////////////////////////////////////////////////////////
/// @brief the initial default connection
////////////////////////////////////////////////////////////////////////////////

V8ClientConnection* ClientConnection = 0;

////////////////////////////////////////////////////////////////////////////////
/// @brief object template for the initial connection
Expand Down Expand Up @@ -158,12 +164,6 @@ static vector<string> UnitTests;

static vector<string> JsLint;

////////////////////////////////////////////////////////////////////////////////
/// @brief command prompt
////////////////////////////////////////////////////////////////////////////////

static string Prompt = "arangosh [%d]> ";

// -----------------------------------------------------------------------------
// --SECTION-- JavaScript functions
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand All @@ -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)
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion etc/Makefile.files
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions etc/arangodb/foxx-manager.conf.in
Original file line number Diff line number Diff line change
@@ -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);
10 changes: 10 additions & 0 deletions etc/relative/foxx-manager.conf
Original file line number Diff line number Diff line change
@@ -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);
24 changes: 24 additions & 0 deletions lib/BasicsC/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions lib/BasicsC/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 1ef5967

Please sign in to comment.