什么是在OpenShift v2推送钩期间的最后一秒重置PATH变量?

Kev*_*Kev 13 git ssh node.js openshift openshift-cartridge

TL; DR:工作应用程序,克隆它,克隆无法从推送挂钩正确启动(但如果我在ssh中手动工作正常.) PATH已添加正确的节点版本,但在最后一步的某处,错误的节点版本被前置到PATH一次.

路径在这里是正确的:

remote:     PATH = /var/lib/openshift/.../app-root/data//node-v4.x.x-linux-x64/bin:/var/lib/openshift/.../app-root/runtime/repo/node_modules/.bin:/var/lib/openshift/...//.node_modules/.bin:/opt/rh/nodejs010/root/usr/bin:/bin:/usr/bin:/usr/sbin
Run Code Online (Sandbox Code Playgroud)

然后立即错误,在这里的某个地方:

remote: Starting NodeJS cartridge
remote: Tue Aug 22 2017 15:39:10 GMT-0400 (EDT): Starting application 'staging' ...
Run Code Online (Sandbox Code Playgroud)

那么在最后两行中或之前表示了哪些脚本和钩子? PATH不只是为自己添加线条......


我有一个运行OpenJhift v2应用程序,运行NodeJS版本,足以支持胖箭头表示法.

它似乎是根据Openshift上的Custom node.js版本设置的,因为该repo中的脚本(用于使用标记文件)存在于.openshift.

rhc create --from-app根据工作原理设置了第二个,重置了repo,然后重新部署到它上面.第二个工作很好,除了最后一步node:

remote: npm info ok 
remote: NOTE: The .openshift/action_hooks/build hook is not executable, to make it executable:
remote:       On Windows run:   git update-index --chmod=+x .openshift/action_hooks/build
remote:       On Linux/OSX run: chmod +x .openshift/action_hooks/build
remote: Preparing build for deployment
remote: Deployment id is cedf7f51
remote: Activating deployment
remote: NOTE: The .openshift/action_hooks/deploy hook is not executable, to make it executable:
remote:       On Windows run:   git update-index --chmod=+x .openshift/action_hooks/deploy
remote:       On Linux/OSX run: chmod +x .openshift/action_hooks/deploy
remote: 
remote:   - pre_start_nodejs: Adding Node.js version 4.x.x binaries to path
remote:   - PATH set to include custom node version (4.x.x) from
remote:        /var/lib/openshift/.../app-root/data//node-v4.x.x-linux-x64/bin 
remote:     PATH = /var/lib/openshift/.../app-root/data//node-v4.x.x-linux-x64/bin:/var/lib/openshift/.../app-root/runtime/repo/node_modules/.bin:/var/lib/openshift/...//.node_modules/.bin:/opt/rh/nodejs010/root/usr/bin:/bin:/usr/bin:/usr/sbin
remote: Starting NodeJS cartridge
remote: Tue Aug 22 2017 15:39:10 GMT-0400 (EDT): Starting application 'staging' ...
remote: Waiting for application port (8080) become available ...
Run Code Online (Sandbox Code Playgroud)

(到目前为止,所有内容与工作应用程序完全一样,除了名称.)

remote: Application 'staging' failed to start (port 8080 not available)
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: ... (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/.../nodejs
remote: #<IO:0x00000001cd42d0>
remote: #<IO:0x00000001cd4258>
remote: )
remote: Deployment completed with status: failure
remote: postreceive failed
Run Code Online (Sandbox Code Playgroud)

rhc envrhc app show显示设置在所有方式上都是相同的.

我从其他问题中得知,上面的"端口8080"部分是红鲱鱼.另外,如果我rhc ssh进入并手动node www.js,它使用该端口就可以了,我可以通过浏览器访问该应用程序.

所以我调查了使用rhc tail.由于脂肪箭头符号,我可以看到它无法重复启动:

pg.on('error', (err) => {
                      ^
SyntaxError: Unexpected token >
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
...
DEBUG: Program node ./www.js exited with code 8
DEBUG: Starting child process with 'node ./www.js'
Run Code Online (Sandbox Code Playgroud)

然而,如果我rhc ssh进入同一台服务器并运行node --version,我会得到更新的版本(与其他服务器版本相同,它都从.openshift我部署的目录中的标记文件中提取它.)

我猜不知道推送钩的最后一步是使用Node 0.10,因为这就是两个应用程序上命名的盒式磁带.但是,如果我检查添加的路径PATH,那么较新的Node版本确实存在.

然而,这是事情变得有趣的地方.在PATH上面的报道(其中4.XX被预先计划)是不再受时间节点的路径启动.我改变www.js了只是吐出来process.env.PATH并比较两者.后者将这两条路径添加到开头!

/opt/rh/nodejs010/root/usr/bin
/opt/rh/v8314/root/usr/bin
Run Code Online (Sandbox Code Playgroud)

这是做什么的,我怎么能阻止它呢?在这些产出线中甚至有机会?

remote:     PATH = /var/lib/openshift/.../app-root/data//node-v4.x.x-linux-x64/bin:/var/lib/openshift/.../app-root/runtime/repo/node_modules/.bin:/var/lib/openshift/...//.node_modules/.bin:/opt/rh/nodejs010/root/usr/bin:/bin:/usr/bin:/usr/sbin
remote: Starting NodeJS cartridge
remote: Tue Aug 22 2017 15:39:10 GMT-0400 (EDT): Starting application 'staging' ...
Run Code Online (Sandbox Code Playgroud)

(为什么只是在我的第二个应用程序上,当我--from-app以前创建它时,所有其他设置似乎在两者之间相等?)

Kev*_*Kev 5

在应用程序最初用于定制它的NodeJS版本的129个回购中的一个中,有一个问题的评论解决了它:

添加一行到.openshift\lib\utils:

#  Add the node binary path to the PATH.
export OPENSHIFT_NODEJS_VERSION=0.6 ### this is the new line
export PATH="$node_bin_path:${PATH}"
Run Code Online (Sandbox Code Playgroud)

"重要的是,就像你提到的那样,它被设定为0.6,即使你没有运行0.6."

同样重要的是它设置为0.6,即使您恢复的原始Node版本也不是0.6.(我尝试了0.10,没有运气.这里是0.6的神奇答案.)