INNER CODE UNIT · TypeScript
_runWrk2
hasura/graphql-bench · app/queries/src/executors/wrk2/index.ts:176
private async _runWrk2(metadata: RunWrk2Metadata, config: Wrk2BinaryArgs) {
const wrkPath = await this.getBinaryPath()
const start = new Date()
const wrk = execa(wrkPath, this._makeWrk2CmdArgs(config), {
env: {
// This is a bit hairy. We need the "graphql-bench.lua" script to be able to call require("json").
// By default, Lua files can "require" any other file in the same directory the program was run from. The "module context" is "./".
// The way that Lua modules work is that it tries to substitute the name of the require()'d module with any "?" character in each pattern in LUA_PATH.
// (Patterns are separated by semicolons)
// So what we need to do is call wrk and set up LUA_PATH with a pattern that when "?" is filled in with "json" it points to the "json.lua" file.
// To do this, we need to point it to the absolute path of:
// ./app/queries/bin/wrk/json.lua
// So, to accomplish this we set LUA_PATH to:
// ./app/queries/bin/wrk/?.lua
LUA_PATH: path.join(this.localBinaryFolder, 'wrk', '?.lua;;'),
},
})
wrk.stdout.pipe(process.stdout)