Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { IModelHost, IModelHostConfiguration } from "@bentley/imodeljs-backend";
import { Config } from "@bentley/imodeljs-clients";
import { IModelJsExpressServer } from "@bentley/express-server";
import { BentleyCloudRpcManager, ElectronRpcConfiguration, ElectronRpcManager, RpcConfiguration } from "@bentley/imodeljs-common";
import { rpcInterfaces } from "../common/RpcInterfaces";
import "./RpcImpl";
IModelJsConfig.init(true, true, Config.App);
RpcConfiguration.developmentMode = true;
// Start the backend
const hostConfig = new IModelHostConfiguration();
hostConfig.concurrentQuery.concurrent = 2;
hostConfig.concurrentQuery.pollInterval = 5;
IModelHost.startup(hostConfig);
Logger.initializeToConsole();
Logger.setLevel("imodeljs-backend.IModelReadRpcImpl", LogLevel.Error); // Change to trace to debug
Logger.setLevel("imodeljs-backend.IModelDb", LogLevel.Error); // Change to trace to debug
Logger.setLevel("Performance", LogLevel.Error); // Change to Info to capture
async function init() {
if (ElectronRpcConfiguration.isElectron) {
ElectronRpcManager.initializeImpl({}, rpcInterfaces);
} else {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "integration-test", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { IModelHost, IModelHostConfiguration } from "@bentley/imodeljs-backend";
import { Config } from "@bentley/imodeljs-clients";
import { BentleyCloudRpcManager, ElectronRpcConfiguration, ElectronRpcManager, RpcConfiguration } from "@bentley/imodeljs-common";
import { IModelJsExpressServer } from "@bentley/express-server";
import { rpcInterfaces } from "../common/RpcInterfaces";
import "./RpcImpl";
IModelJsConfig.init(true, true, Config.App);
RpcConfiguration.developmentMode = true;
// Start the backend
const hostConfig = new IModelHostConfiguration();
IModelHost.startup(hostConfig);
Logger.initializeToConsole();
Logger.setLevel("imodeljs-backend.IModelReadRpcImpl", LogLevel.Error); // Change to trace to debug
Logger.setLevel("imodeljs-backend.IModelDb", LogLevel.Error); // Change to trace to debug
Logger.setLevel("Performance", LogLevel.Error); // Change to Info to capture
async function init() {
if (ElectronRpcConfiguration.isElectron) {
ElectronRpcManager.initializeImpl({}, rpcInterfaces);
} else {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "perf-tests", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
const port = Number(process.env.CERTA_PORT || 3011) + 2000;
const server = new IModelJsExpressServer(rpcConfig.protocol);
export function initializeBackend() {
setupStandaloneConfiguration();
const hostConfig = new IModelHostConfiguration();
if (!MobileRpcConfiguration.isMobileBackend) {
// tslint:disable-next-line:no-var-requires
const configPathname = path.normalize(path.join(__dirname, "../webresources", "configuration.json"));
const svtConfig: SVTConfiguration = require(configPathname);
if (svtConfig.customOrchestratorUri)
hostConfig.imodelClient = new IModelBankClient(svtConfig.customOrchestratorUri, new UrlFileHandler());
}
IModelHost.startup(hostConfig);
}
export function initializeBackend() {
const svtConfig = setupStandaloneConfiguration();
const hostConfig = new IModelHostConfiguration();
hostConfig.logTileLoadTimeThreshold = 3;
hostConfig.logTileSizeThreshold = 500000;
let logLevel = LogLevel.None;
if (MobileRpcConfiguration.isMobileBackend) {
// Does not seem SVTConfiguraiton is used anymore.
} else {
if (svtConfig.customOrchestratorUri)
hostConfig.imodelClient = new IModelBankClient(svtConfig.customOrchestratorUri, new UrlFileHandler());
if (svtConfig.useFakeCloudStorageTileCache)
hostConfig.tileCacheCredentials = { service: "external", account: "", accessKey: "" };
const logLevelEnv = process.env.SVT_LOG_LEVEL as string;
if (undefined !== logLevelEnv)
logLevel = Logger.parseLogLevel(logLevelEnv);
public constructor(hubUtility = new HubUtility()) {
this._hubUtility = hubUtility;
Logger.initializeToConsole();
Logger.setLevelDefault(LogLevel.Error);
Logger.setLevel(QueryAgentConfig.loggingCategory, LogLevel.Trace);
if (process.env.NODE_ENV === "development") {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
Logger.logTrace(QueryAgentConfig.loggingCategory, "Setting NODE_TLS_REJECT_UNAUTHORIZED = 0");
}
// Startup IModel Host if we need to
const configuration = new IModelHostConfiguration();
if (!IModelHost.configuration)
IModelHost.startup(configuration);
}
public static startupIModelHost() {
// The host configuration.
// The defaults will work for most backends.
// Here is an example of how the briefcasesCacheDir property of the host configuration
// could be set from an environment variable, which could be set by a cloud deployment mechanism.
let briefcaseCacheDir = process.env.MY_SERVICE_BRIEFCASES_DIR;
if (briefcaseCacheDir === undefined) {
const tempDir = process.env.MY_SERVICE_TMP_DIR || KnownLocations.tmpdir;
briefcaseCacheDir = path.join(tempDir, "iModelJs_cache");
}
const imHostConfig = new IModelHostConfiguration();
imHostConfig.briefcaseCacheDir = briefcaseCacheDir;
// Start up IModelHost, supplying the configuration.
IModelHost.startup(imHostConfig);
}
// __PUBLISH_EXTRACT_END__
public static initialize(_requestContext: ClientRequestContext) {
const config = new IModelHostConfiguration();
if (Platform.isNodeJs)
config.appAssetsDir = path.join(__dirname, "assets");
else
config.appAssetsDir = KnownLocations.packageAssetsDir;
IModelHost.startup(config);
// Can't to this, as our logging config uses Bunyan/Seq, and we don't really want to do that here.
// initializeLogging();
RpcManager.registerImpl(RobotWorldWriteRpcInterface, RobotWorldWriteRpcImpl); // register impls that we don't want in the doc example
this.registerImpls();
const interfaces = this.chooseInterfacesToExpose();
if (this._features.check("robot.imodel.readwrite")) // choose add'l interfaces that we don't want in the doc example
interfaces.push(IModelWriteRpcInterface);
TestRpcManager.initialize(interfaces);
if (inputArgs.duplicateIbim)
outputIModel.closeStandalone();
return true;
}
Yargs.usage("Import a Syncro JSON animation script into an existing IBIM file.");
Yargs.required("input", "The input IBIM");
Yargs.default("fixRange", true, "Set the project extents to the range of all geometry");
Yargs.default("createSeparateScript", true, "Create a separate file with the JSON for the animation script (debugging)");
Yargs.default("createDuplicateIbim", true, "Create a duplicate IBIM with the imported script (rather than writing to original)");
Yargs.required("script", "Animation script JSON file");
Yargs.string("script");
const args = Yargs.parse() as Yargs.Arguments;
IModelHost.startup(new IModelHostConfiguration());
doImport(args);
private _initializeIModelHost(): void {
const configuration = new IModelHostConfiguration();
IModelHost.startup(configuration);
}
/** Clean up the test output directory to prepare for fresh output */