mirror of https://gitee.com/bigwinds/arangodb
slash all left over processes (if) and set status to bad. (#7557)
This commit is contained in:
parent
643b58a347
commit
879c7bb479
|
@ -10,6 +10,7 @@ const internalMembers = UnitTest.internalMembers;
|
|||
const fs = require('fs');
|
||||
const internal = require('internal'); // js/common/bootstrap/modules/internal.js
|
||||
const inspect = internal.inspect;
|
||||
const abortSignal = 6;
|
||||
|
||||
let testOutputDirectory;
|
||||
|
||||
|
@ -312,7 +313,13 @@ function main (argv) {
|
|||
// creates yaml like dump at the end
|
||||
UnitTest.unitTestPrettyPrintResults(res, testOutputDirectory, options);
|
||||
|
||||
return res.status;
|
||||
let running = require("internal").getExternalSpawned();
|
||||
let i = 0;
|
||||
for (i = 0; i < running.length; i++) {
|
||||
print("Killing remaining process: " + JSON.stringify(running[i]));
|
||||
print(require("internal").killExternal(running[i].pid, abortSignal));
|
||||
};
|
||||
return res.status && running.length === 0;
|
||||
}
|
||||
|
||||
let result = main(ARGUMENTS);
|
||||
|
|
|
@ -624,6 +624,15 @@ global.DEFINE_MODULE('internal', (function () {
|
|||
delete global.SYS_EXECUTE_EXTERNAL_AND_WAIT;
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
// / @brief getExternalSpawned
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (global.SYS_GET_EXTERNAL_SPAWNED) {
|
||||
exports.getExternalSpawned = global.SYS_GET_EXTERNAL_SPAWNED;
|
||||
delete global.SYS_GET_EXTERNAL_SPAWNED;
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
// / @brief killExternal
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -66,7 +66,7 @@ uint64_t TRI_PhysicalMemory;
|
|||
/// @brief all external processes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static std::vector<ExternalProcess*> ExternalProcesses;
|
||||
std::vector<ExternalProcess*> ExternalProcesses;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief lock for protected access to vector ExternalProcesses
|
||||
|
|
|
@ -127,6 +127,12 @@ struct ExternalProcess {
|
|||
/// @brief external process status
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern std::vector<ExternalProcess*> ExternalProcesses;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief external process status
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct ExternalProcessStatus {
|
||||
TRI_external_status_e _status;
|
||||
int64_t _exitStatus;
|
||||
|
|
|
@ -3610,6 +3610,38 @@ static void convertStatusToV8(v8::FunctionCallbackInfo<v8::Value> const& args,
|
|||
TRI_V8_TRY_CATCH_END;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief lists all running external processes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void JS_GetExternalSpawned(
|
||||
v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||
TRI_V8_TRY_CATCH_BEGIN(isolate);
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
// extract the arguments
|
||||
if (args.Length() != 0) {
|
||||
TRI_V8_THROW_EXCEPTION_USAGE("getExternalSpawned()");
|
||||
}
|
||||
|
||||
v8::Handle<v8::Array> spawnedProcesses =
|
||||
v8::Array::New(isolate, static_cast<int>(ExternalProcesses.size()));
|
||||
|
||||
uint32_t i = 0;
|
||||
for (auto const& process : ExternalProcesses) {
|
||||
v8::Handle<v8::Object> oneProcess = v8::Object::New(isolate);
|
||||
ExternalId external;
|
||||
external._pid = process->_pid;
|
||||
auto external_status = TRI_CheckExternalProcess(external, false);
|
||||
convertStatusToV8(args, oneProcess, external_status, external);
|
||||
spawnedProcesses->Set(i, oneProcess);
|
||||
i++;
|
||||
}
|
||||
|
||||
TRI_V8_RETURN(spawnedProcesses);
|
||||
TRI_V8_TRY_CATCH_END
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief executes a external program
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -4787,6 +4819,11 @@ void TRI_InitV8Utils(v8::Isolate* isolate, v8::Handle<v8::Context> context,
|
|||
TRI_AddGlobalFunctionVocbase(isolate,
|
||||
TRI_V8_ASCII_STRING(isolate, "SYS_SPLIT_WORDS_ICU"),
|
||||
JS_SplitWordlist);
|
||||
|
||||
|
||||
TRI_AddGlobalFunctionVocbase(isolate,
|
||||
TRI_V8_ASCII_STRING(isolate, "SYS_GET_EXTERNAL_SPAWNED"),
|
||||
JS_GetExternalSpawned);
|
||||
TRI_AddGlobalFunctionVocbase(isolate,
|
||||
TRI_V8_ASCII_STRING(isolate, "SYS_KILL_EXTERNAL"),
|
||||
JS_KillExternal);
|
||||
|
|
Loading…
Reference in New Issue