mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'sharding' of https://github.com/triAGENS/ArangoDB into sharding
This commit is contained in:
commit
1158400fa6
|
@ -702,31 +702,6 @@ void ArangoServer::buildApplicationServer () {
|
|||
|
||||
LOG_INFO("using default language '%s'", languageName.c_str());
|
||||
|
||||
/*
|
||||
OperationMode::server_operation_mode_e mode = OperationMode::determineMode(_applicationServer->programOptions());
|
||||
|
||||
if (mode == OperationMode::MODE_CONSOLE ||
|
||||
mode == OperationMode::MODE_UNITTESTS ||
|
||||
mode == OperationMode::MODE_SCRIPT) {
|
||||
|
||||
#ifdef TRI_ENABLE_CLUSTER
|
||||
// we need to prepare the cluster even in console mode
|
||||
_applicationCluster->disableHeartbeat();
|
||||
_applicationCluster->prepare();
|
||||
_applicationCluster->start();
|
||||
_applicationCluster->open();
|
||||
#endif
|
||||
|
||||
int res = executeConsole(mode);
|
||||
|
||||
#ifdef TRI_ENABLE_CLUSTER
|
||||
_applicationCluster->close();
|
||||
_applicationCluster->stop();
|
||||
#endif
|
||||
|
||||
TRI_EXIT_FUNCTION(res, NULL);
|
||||
}
|
||||
*/
|
||||
// if we got here, then we are in server mode
|
||||
|
||||
// .............................................................................
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<body>
|
||||
HHALO
|
||||
<nav class="navbar">
|
||||
<div class="resizecontainer">
|
||||
<div class="navlogo">
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
COLOR_BOLD_WHITE, COLOR_YELLOW, COLOR_BOLD_YELLOW, COLOR_CYAN, COLOR_BOLD_CYAN, COLOR_MAGENTA,
|
||||
COLOR_BOLD_MAGENTA, PRETTY_PRINT, VALGRIND, VERSION, UPGRADE,
|
||||
BYTES_SENT_DISTRIBUTION, BYTES_RECEIVED_DISTRIBUTION, CONNECTION_TIME_DISTRIBUTION,
|
||||
REQUEST_TIME_DISTRIBUTION, DEVELOPMENT_MODE, THREAD_NUMBER, LOGFILE_PATH,
|
||||
REQUEST_TIME_DISTRIBUTION, DEVELOPMENT_MODE, FE_DEVELOPMENT_MODE, THREAD_NUMBER, LOGFILE_PATH,
|
||||
SYS_PLATFORM, SYS_EXECUTE_EXTERNAL, SYS_STATUS_EXTERNAL, SYS_KILL_EXTERNAL */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -524,6 +524,18 @@ testFuncs.single = function (options) {
|
|||
|
||||
};
|
||||
|
||||
testFuncs.http_server = function (options) {
|
||||
var instanceInfo = startInstance("tcp",options);
|
||||
var result = {};
|
||||
|
||||
|
||||
|
||||
print("Shutting down...");
|
||||
shutdownInstance(instanceInfo,options);
|
||||
print("done.");
|
||||
return result;
|
||||
};
|
||||
|
||||
testFuncs.dummy = function (options) {
|
||||
var instanceInfo = startInstance("tcp",options);
|
||||
print("Startup done.");
|
||||
|
|
|
@ -319,6 +319,8 @@ bool createPipes (HANDLE * hChildStdinRd, HANDLE * hChildStdinWr,
|
|||
|
||||
// create a pipe for the child process's STDIN
|
||||
if (! CreatePipe(hChildStdinRd, hChildStdinWr, &saAttr, 0)) {
|
||||
CloseHandle(hChildStdoutRd);
|
||||
CloseHandle(hChildStdoutWr);
|
||||
LOG_ERROR("stdin pipe creation failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -476,7 +478,7 @@ static void StartExternalProcess (TRI_external_t* external, bool usePipes) {
|
|||
// now create the child process.
|
||||
fSuccess = startProcess(external, hChildStdinRd, hChildStdoutWr);
|
||||
if (! fSuccess) {
|
||||
external->_status = TRI_EXT_PIPE_FAILED;
|
||||
external->_status = TRI_EXT_FORK_FAILED;
|
||||
|
||||
CloseHandle(hChildStdoutRd);
|
||||
CloseHandle(hChildStdoutWr);
|
||||
|
@ -788,7 +790,7 @@ void TRI_SetProcessTitle (char const* title) {
|
|||
void TRI_CreateExternalProcess (const char* executable,
|
||||
const char** arguments,
|
||||
size_t n,
|
||||
TRI_external_id_t * pid) {
|
||||
TRI_external_id_t* pid) {
|
||||
TRI_external_t* external;
|
||||
|
||||
size_t i;
|
||||
|
@ -810,20 +812,28 @@ void TRI_CreateExternalProcess (const char* executable,
|
|||
external->_status = TRI_EXT_NOT_STARTED;
|
||||
|
||||
StartExternalProcess(external, false);
|
||||
if (external->_status != TRI_EXT_RUNNING) {
|
||||
#ifndef _WIN32
|
||||
pid->pid = -1;
|
||||
#else
|
||||
pid->_hProcess = 0;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
TRI_LockMutex(&ExternalProcessesLock);
|
||||
TRI_PushBackVectorPointer(&ExternalProcesses, external);
|
||||
#ifndef _WIN32
|
||||
*pid = external->_pid;
|
||||
pid->pid = external->_pid;
|
||||
pid->readPipe = external->_readPipe;
|
||||
pid->writePipe = external->_writePipe;
|
||||
#else
|
||||
pid->_hProcess = external->_pid;
|
||||
pid->_hChildStdoutRd = external->_readPipe;
|
||||
pid->_hChildStdinWr = external->_writePipe;
|
||||
pid->_hProcess = external->_pid;
|
||||
pid->_hChildStdoutRd = external->_readPipe;
|
||||
pid->_hChildStdinWr = external->_writePipe;
|
||||
|
||||
#endif
|
||||
TRI_UnlockMutex(&ExternalProcessesLock);
|
||||
|
||||
// TRI_Free(TRI_CORE_MEM_ZONE, external);
|
||||
}
|
||||
|
||||
|
||||
|
@ -850,7 +860,7 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
|
|||
for (i = 0; i < ExternalProcesses._length; ++i) {
|
||||
external = TRI_AtVectorPointer(&ExternalProcesses, i);
|
||||
|
||||
if (external->_pid == pid) {
|
||||
if (external->_pid == pid.pid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -952,7 +962,7 @@ TRI_external_status_t TRI_CheckExternalProcess (HANDLE hProcess,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief kills an external process
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TRI_KillExternalProcess (pid_t pid) {
|
||||
void TRI_KillExternalProcess (TRI_external_id_t pid) {
|
||||
TRI_external_t* external;
|
||||
size_t i;
|
||||
|
||||
|
@ -961,7 +971,7 @@ void TRI_KillExternalProcess (pid_t pid) {
|
|||
for (i = 0; i < ExternalProcesses._length; ++i) {
|
||||
external = TRI_AtVectorPointer(&ExternalProcesses, i);
|
||||
|
||||
if (external->_pid == pid) {
|
||||
if (external->_pid == pid.pid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,11 @@ TRI_external_status_e;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WIN32
|
||||
typedef TRI_pid_t TRI_external_id_t;
|
||||
typedef struct TRI_external_id_s {
|
||||
TRI_pid_t pid;
|
||||
int readPipe;
|
||||
int writePipe;
|
||||
} TRI_external_id_t;
|
||||
#else
|
||||
typedef struct TRI_external_id_s {
|
||||
HANDLE _hProcess;
|
||||
|
@ -107,7 +111,7 @@ typedef struct TRI_external_s {
|
|||
char** _arguments;
|
||||
|
||||
#ifndef _WIN32
|
||||
TRI_external_id_t _pid;
|
||||
TRI_pid_t _pid;
|
||||
int _readPipe;
|
||||
int _writePipe;
|
||||
#else
|
||||
|
@ -186,20 +190,22 @@ void TRI_CreateExternalProcess (const char* executable,
|
|||
/// @brief returns the status of an external process
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_external_status_t TRI_CheckExternalProcess (pid_t pid, bool wait);
|
||||
TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
|
||||
bool wait);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief kills an external process
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_KillExternalProcess (pid_t pid);
|
||||
void TRI_KillExternalProcess (TRI_external_id_t pid);
|
||||
|
||||
#else
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the status of an external process
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_external_status_t TRI_CheckExternalProcess (HANDLE hProcess);
|
||||
TRI_external_status_t TRI_CheckExternalProcess (HANDLE hProcess,
|
||||
bool wait);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief kills an external process
|
||||
|
|
|
@ -2497,7 +2497,20 @@ static v8::Handle<v8::Value> JS_ExecuteExternal (v8::Arguments const& argv) {
|
|||
TRI_Free(TRI_CORE_MEM_ZONE, arguments);
|
||||
}
|
||||
#ifndef _WIN32
|
||||
return scope.Close(v8::Number::New(external));
|
||||
if (external.pid < 0) {
|
||||
TRI_V8_ERROR(scope, "Process could not be started");
|
||||
}
|
||||
v8::Handle<v8::Object> result = v8::Object::New();
|
||||
result->Set(v8::String::New("pid"), v8::Number::New(external.pid));
|
||||
if (external.readPipe >= 0) {
|
||||
result->Set(v8::String::New("readPipe"),
|
||||
v8::Number::New(external.readPipe));
|
||||
}
|
||||
if (external.writePipe >= 0) {
|
||||
result->Set(v8::String::New("writePipe"),
|
||||
v8::Number::New(external.writePipe));
|
||||
}
|
||||
return scope.Close(result);
|
||||
#else
|
||||
size_t pid_len, readPipe_len, writePipe_len;
|
||||
char * hProcess = NULL;
|
||||
|
@ -2507,7 +2520,7 @@ static v8::Handle<v8::Value> JS_ExecuteExternal (v8::Arguments const& argv) {
|
|||
if (external._hProcess) {
|
||||
hProcess = TRI_EncodeHexString((const char *)&external._hProcess, sizeof(HANDLE), &pid_len);
|
||||
} else {
|
||||
TRI_V8_TYPE_ERROR(scope, "Internal Error, Process could not be started");
|
||||
TRI_V8_ERROR(scope, "Internal Error, Process could not be started");
|
||||
}
|
||||
|
||||
|
||||
|
@ -2542,13 +2555,21 @@ static v8::Handle<v8::Value> JS_ExecuteExternal (v8::Arguments const& argv) {
|
|||
|
||||
static v8::Handle<v8::Value> JS_StatusExternal (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::String> pidname = v8::String::New("pid");
|
||||
|
||||
// extract the arguments
|
||||
if (argv.Length() < 1 || argv.Length() > 2) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "statusExternal(<external-identifier>, <wait>)");
|
||||
if (argv.Length() < 1 || argv.Length() > 2 ||
|
||||
!argv[0]->IsObject()) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "statusExternal(<external-identifier>[, <wait>])");
|
||||
}
|
||||
|
||||
TRI_external_id_t pid = TRI_ObjectToUInt64(argv[0], true);
|
||||
v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(argv[0]);
|
||||
if (!obj->Has(pidname)) {
|
||||
TRI_V8_EXCEPTION_MESSAGE(scope, TRI_ERROR_BAD_PARAMETER,
|
||||
"statusExternal: pid must be given");
|
||||
}
|
||||
TRI_external_id_t pid;
|
||||
pid.pid = static_cast<TRI_pid_t>(TRI_ObjectToUInt64(obj->Get(pidname), true));
|
||||
bool wait = false;
|
||||
if (argv.Length() == 2) {
|
||||
wait = TRI_ObjectToBoolean(argv[1]);
|
||||
|
@ -2586,20 +2607,29 @@ static v8::Handle<v8::Value> JS_StatusExternal (v8::Arguments const& argv) {
|
|||
|
||||
static v8::Handle<v8::Value> JS_KillExternal (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::String> pidname = v8::String::New("pid");
|
||||
|
||||
// extract the arguments
|
||||
if (argv.Length() != 1) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "killExternal(<external-identifier>)");
|
||||
}
|
||||
|
||||
TRI_external_id_t pid = TRI_ObjectToUInt64(argv[0], true);
|
||||
v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(argv[0]);
|
||||
if (!obj->Has(pidname)) {
|
||||
TRI_V8_EXCEPTION_MESSAGE(scope, TRI_ERROR_BAD_PARAMETER,
|
||||
"statusExternal: pid must be given");
|
||||
}
|
||||
TRI_external_id_t pid;
|
||||
pid.pid = static_cast<TRI_pid_t>(TRI_ObjectToUInt64(obj->Get(pidname), true));
|
||||
|
||||
TRI_KillExternalProcess(pid);
|
||||
|
||||
// return the result
|
||||
return scope.Close(v8::Undefined());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief kills an external process
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2646,17 +2676,26 @@ static v8::Handle<v8::Value> JS_KillExternal (v8::Arguments const& argv) {
|
|||
|
||||
static v8::Handle<v8::Value> JS_StatusExternal (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::String> pidname = v8::String::New("pid");
|
||||
|
||||
// extract the arguments
|
||||
if (argv.Length() != 1 || !argv[0]->IsString()) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "statusExternal(<external-identifier>)");
|
||||
if (argv.Length() < 1 || argv.Length() > 2 || !argv[0]->IsObject()) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "statusExternal(<external-identifier>[, <wait>])");
|
||||
}
|
||||
|
||||
string hProcessStr = TRI_ObjectToString(argv[0]);
|
||||
v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(argv[0]);
|
||||
if (!obj->Has(pidname)) {
|
||||
TRI_V8_EXCEPTION_MESSAGE(scope, TRI_ERROR_BAD_PARAMETER,
|
||||
"statusExternal: pid must be given");
|
||||
}
|
||||
bool wait = false;
|
||||
if (argv.Length() == 2) {
|
||||
wait = TRI_ObjectToBoolean(argv[1]);
|
||||
}
|
||||
string hProcessStr = TRI_ObjectToString(obj->Get(pidname));
|
||||
size_t pid_len;
|
||||
char * hProcessCharPtr = TRI_DecodeHexString(hProcessStr.c_str(), hProcessStr.size(), &pid_len);
|
||||
HANDLE hProcess = (HANDLE)(*((intptr_t* )hProcessCharPtr));
|
||||
TRI_external_status_t external = TRI_CheckExternalProcess(hProcess);
|
||||
TRI_external_status_t external = TRI_CheckExternalProcess(hProcess, wait);
|
||||
|
||||
v8::Handle<v8::Object> result = v8::Object::New();
|
||||
const char* status = "UNKNOWN";
|
||||
|
|
Loading…
Reference in New Issue