如何在 Hybris Commerce Server start 上启动节点服务器

How can I start node server on Hybris Commerce Server start

SAP 商务 1905

我有一个节点应用程序,我想将其与我的 Hybris 集成。我创建了一个自定义插件并将我的节点应用程序文件放在插件扩展中。现在我想 运行 在 Hybris 服务器上启动以下命令。

nohup npm start > output.log&

我可以通过在 myextension_compileuisrc_executor buildcallback.

下放置 npm 命令来在 ant build 上启动我的节点服务器

但我的目标是仅在 myextension_compileuisrc_executor 上执行 npm 安装,而不是节点服务器启动。

这就是为什么我正在查看在 Hybris Server Start 上启动 node.js 服务器的方式。我在 buildcallback 中找不到任何目标,我可以在其中注入我的服务器启动命令。

如何实现?

更新:

也尝试过 myextension_before_startHybrisServer 但没有成功 -

<macrodef name="myextension_before_startHybrisServer">

    <sequential>

        <npm-start/>

    </sequential>

</macrodef>

您好,请尝试在构建回调中编写自定义微。

<macrodef name="xxxstorefront_getnpm">
 <sequential>


        <echo message="Checking for NPM" />

        <if>
            <os family="windows" />
            <then>
                <exec dir="${platformhome}" executable="cmd.exe" osfamily="windows">
                    <arg line="/c" />
                    <arg line="npm.bat" />
                </exec>
            </then>
            <else>
                <exec dir="${platformhome}" executable="sh" osfamily="unix">
                    <arg line="-c ./npm.sh" />
                </exec>
            </else>
        </if>


    </sequential>
</macrodef>

然后像这样添加这个回调的引用。

<macrodef name="xxxstorefront_compileuisrc_executor">
    <sequential>
        <xxxstorefront_getnpm/>

    </sequential>
</macrodef>

您可以尝试一种解决方法。

请制作这样的文件夹\hybris\config\customize\platform\resourcesant/platformadministration.xml

并复制现有的 platformadministration.xml 并创建自己的微定义:

<macrodef name="xxxstorefront_getnpm">

    <echo message="Checking for NPM" />

    <if>
        <os family="windows" />
        <then>
            <exec dir="${platformhome}" executable="cmd.exe" osfamily="windows">
                <arg line="/c" />
                <arg line="npm.bat" />
            </exec>
        </then>
        <else>
            <exec dir="${platformhome}" executable="sh" osfamily="unix">
                <arg line="-c ./npm.sh" />
            </exec>
        </else>
    </if>


</sequential>

然后创建文件 \hybris\config\customize\platform\build.xml

并在 build.xml 的正上方添加新创建的微定义。

 <target name="startHybrisServer" description="Starts the hybris Server">
    <callback extname="" target="before_startHybrisServer"/>
    <--**CUSTOM MICRO DEF**>
    <startHybrisServer/>
    <callback extname="" target="after_startHybrisServer"/>
</target>

然后保存文件并运行 >> ant customize.

ant clean all && hybrisserver.bat

嗨,我试着写了普通的宏

    <sequential>
        <echo message="JJJJJJ RAUSHAN JAAAA" />

    </sequential>

</macrodef>

output:
 [echo] JJJJJJ RAUSHAN JAAAA
     [echo] Checking lock flag for the platform
     [exec] --> Wrapper Started as Console
     [exec] Java Service Wrapper Professional Edition 64-bit 3.5.29

命令:>ant startHybrisServer