Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce shell count by one when configmgr used by using pipe directly #3812

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to the Zowe Installer will be documented in this file.
## `2.16.0

## Minor enhancements/defect fixes
- Enhancement: Reduced resource consumption by removal of one shell process per server that was used when starting each server. (#3812)
- Enhancement: The command `zwe support` now includes CEE Runtime option output to better diagnose issues related to environment customization. (#3799)
- Bugfix: zowe.network.validatePortFree and zowe.network.vipaIp variables were moved from zowe.network to zowe.network.server in the schema but not in the code, causing inability to use them without the workaround of specifying them as environment variables ZWE_NETWORK_VALIDATE_PORT_FREE and ZWE_NETWORK_VIPA_IP instead. Now, the variables match the schema: zowe.network.server is used instead of zowe.network.
- Bugfix: configmgr operations now run with HEAPPOOLS64 set to OFF to avoid abends caused when this parameter is not OFF. (#3799)
Expand Down
24 changes: 22 additions & 2 deletions bin/commands/internal/start/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import * as std from 'cm_std';
import * as os from 'cm_os';
import * as zos from 'zos';
import * as xplatform from 'xplatform';
import * as common from '../../../../libs/common';
import * as config from '../../../../libs/config';
import * as shell from '../../../../libs/shell';
import * as varlib from '../../../../libs/var';
import * as stringlib from '../../../../libs/string';
import * as java from '../../../../libs/java';
import * as fs from '../../../../libs/fs';
import * as component from '../../../../libs/component';
Expand Down Expand Up @@ -93,8 +95,26 @@ export function execute(componentId: string, runInBackground: boolean=false) {
} else {
// wait for all background subprocesses created by bin/start.sh exit
// re-source libs is necessary to reclaim shell functions since this will be executed in a new shell
//TODO does this do the same as the shell script before it?
shell.execSync('sh', '-c', `cd ${COMPONENT_DIR} ; cat "${fullPath}" | { echo ". \"${ZOWE_CONFIG.zowe.runtimeDirectory}/bin/libs/configmgr-index.sh\"" ; cat ; echo; echo wait; } | /bin/sh`);
const startScriptContents = `cd ${COMPONENT_DIR} ; . "${ZOWE_CONFIG.zowe.runtimeDirectory}/bin/libs/configmgr-index.sh" ; ${xplatform.loadFileUTF8(fullPath, xplatform.AUTO_DETECT)} ; wait;`;
const pipeArray = os.pipe();
if (!pipeArray) {
common.printFormattedError("ZWELS", "zwe-internal-start-component", `Error ZWEL064E: failed to run command os.pipe - Connot start component ${componentId}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo Connot

return;
}
//TODO this will not work with unicode codepoints longer than a byte
Martin-Zeithaml marked this conversation as resolved.
Show resolved Hide resolved
const buf = new ArrayBuffer(startScriptContents.length);
const view = new Uint8Array(buf);
const ebcdicString = stringlib.asciiToEbcdic(startScriptContents);
for (let i = 0; i < startScriptContents.length; i++) {
view[i] = ebcdicString.charCodeAt(i);
}

os.write(pipeArray[1], buf, 0, startScriptContents.length);
os.close(pipeArray[1]);
os.exec(['/bin/sh'],
{block: true, usePath: true, stdin: pipeArray[0]});
os.close(pipeArray[0]);

}
} else {
common.printFormattedError("ZWELS", "zwe-internal-start-component", `Error ZWEL0172E: Component ${componentId} has commands.start defined but the file is missing.`);
Expand Down
Loading