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

时间:2020-05-02 08:56:36

标签: node.js hybris

SAP Commerce 1905

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

nohup npm start > output.log&

通过将npm命令放在 myextension_compileuisrc_executor buildcallback下,我可以在ant构建上启动节点服务器。

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

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

如何实现?

更新:

也尝试过 myextension_before_startHybrisServer ,但没有运气-

<macrodef name="myextension_before_startHybrisServer">

    <sequential>

        <npm-start/>

    </sequential>

</macrodef>

3 个答案:

答案 0 :(得分:0)

您好,请尝试在自定义回调中编写自定义微型代码。

<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>

答案 1 :(得分:0)

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

请创建一个这样的文件夹\ 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 custom。

ant清理所有&& hybrisserver.bat

答案 2 :(得分:0)

嗨,我尝试编写普通宏

    <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