0
votes

SAP Commerce 1905

I have one node application which i want to integrate with my Hybris. I have created one custom addon and put my node application files inside addon extension. Now i want to run the below command on Hybris server start.

nohup npm start > output.log&

I am able to start my node server on ant build by putting npm command under myextension_compileuisrc_executor buildcallback.

But my goal is to perform only npm install on myextension_compileuisrc_executor not node server start.

Thats why i am looking over the way of starting node.js server on Hybris Server Start. I could not find any target in buildcallback where i can inject my server start command.

How to achieve that ?

UPDATE :

Tried with myextension_before_startHybrisServer as well but no luck -

<macrodef name="myextension_before_startHybrisServer">

    <sequential>

        <npm-start/>

    </sequential>

</macrodef>
3

3 Answers

0
votes

Hi Please try to write custom micro in build-callbacks.

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

Then add reference of this callback like this.

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

    </sequential>
</macrodef>
0
votes

there there is a workaround that you can try.

Please make a folder like this \hybris\config\customize\platform\resourcesant/platformadministration.xml

and copy existing platformadministration.xml and create own micro definitions:

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

then create file \hybris\config\customize\platform\build.xml

and add newly created micro definition in build.xml just above this.

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

Then save file and run >> ant customize.

ant clean all && hybrisserver.bat

0
votes

Hi I tried to write the normal macro

    <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

Command: >ant startHybrisServer