cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

START_APP_CMD for Tomcat on Linux App Service

g_kat
Helper

Hi,

I've been trying to setup OA on a simple Tomcat process with. I have a Linux App service configured for Apache Tomcat 8.5 with Java 8, and I have created a startup scrip based on the documentation

https://docs.dynatrace.com/docs/setup-and-configuration/setup-on-cloud-platforms/microsoft-azure-ser...:

 

I put this script in /home/startup.sh and declared it on the Startup Command field in Web App Settings. I also configured the DT_ variables in the App Settings.

 

From what I've seen on the raw script, it seems that after the LD_PRELOAD it expects to run something:

# Inject variable into the proccess and run the actual application proccess LD_PRELOAD="/opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so" $START_APP_CMD

So, what is the command I need to put there in order for the OA to inject on the Tomcat process?

Regards,

George 

6 REPLIES 6

g_kat
Helper

Also, here is the log since I can't seem to make it work in 1 message:

2024-04-25T09:30:38.811521134Z STARTUP_COMMAND=
2024-04-25T09:30:38.813521392Z Copying /home/startup.sh to /tmp/startup.sh and fixing EOL characters in /tmp/startup.sh
2024-04-25T09:30:38.834581906Z Running STARTUP_FILE: /tmp/startup.sh
2024-04-25T09:30:38.948488027Z + readonly 'LIB_MUSL=musl'
2024-04-25T09:30:38.956471860Z + readonly 'LIB_GCLIB=libc'
2024-04-25T09:30:38.957476289Z + readonly 'LIB_DEFAULT=default'
2024-04-25T09:30:38.957489789Z + readonly 'ALPINE_RELEASE_FILE=/etc/alpine-release'
2024-04-25T09:30:38.957495590Z + readonly 'INSTALLER_DOWNLOAD_PATH=/tmp/installer.sh'
2024-04-25T09:30:38.957500590Z + readonly 'INSTALLER_URL_SUFFIX=api/v1/deployment/installer/agent/unix/paas-sh/latest'
2024-04-25T09:30:38.957899501Z + main
2024-04-25T09:30:38.958134608Z + lib=
2024-04-25T09:30:38.958374715Z + check_ldd
2024-04-25T09:30:38.959259841Z + ldd /bin/echo
2024-04-25T09:30:38.976444842Z + ldd_result=' /lib/ld-musl-x86_64.so.1 (0x7e11e2275000)
2024-04-25T09:30:38.978284196Z libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7e11e2275000)'
2024-04-25T09:30:38.979618635Z + readonly ldd_result
2024-04-25T09:30:38.988081481Z + grep -qi musl
2024-04-25T09:30:38.998547586Z + echo ' /lib/ld-musl-x86_64.so.1 (0x7e11e2275000)
2024-04-25T09:30:38.999750121Z libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7e11e2275000)'
2024-04-25T09:30:39.007408745Z + lib=musl
2024-04-25T09:30:39.008726683Z + test -z musl
2024-04-25T09:30:39.015904292Z + test -z musl
2024-04-25T09:30:39.019697803Z + DT_FLAVOR=musl
2024-04-25T09:30:39.019720504Z + run
2024-04-25T09:30:39.019726604Z + wget -O /tmp/installer.sh -q 'https://{environmentid}.live.dynatrace.com/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api...'
2024-04-25T09:30:50.824393846Z + sh /tmp/installer.sh
2024-04-25T09:30:50.851764421Z 09:30:50 Installing to /opt
2024-04-25T09:30:50.893107091Z 09:30:50 Extracting...
2024-04-25T09:30:53.829458527Z 09:30:53 Unpacking to '/opt/dynatrace/oneagent' ...
2024-04-25T09:31:14.980992878Z 09:31:14 Unpacking complete.
2024-04-25T09:31:15.042335979Z + LD_PRELOAD=/opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
2024-04-25T09:31:15.050484818Z Finished running startup file '/tmp/startup.sh'. Exit code: '0'.
2024-04-25T09:31:15.051052835Z No STARTUP_COMMAND defined.
2024-04-25T09:31:15.051712854Z Starting Tomcat with CATALINA_BASE set to ""
2024-04-25T09:31:15.052701283Z Launched child process with pid: 209
2024-04-25T09:31:15.060163903Z Waiting for main process to exit. GLOBAL_PID_MAIN=209
2024-04-25T09:31:15.060765220Z Waiting for GLOBAL_PID_MAIN == 209
2024-04-25T09:31:15.146008823Z Picked up JAVA_TOOL_OPTIONS: -Xmx1150M -Djava.net.preferIPv4Stack=true

jose_araya
Advisor

Hello George, by looking at the log entries it seems that what is missing is the actual Start up command for your Tomcat Java application. It should point to the location and name of the startup script.sh that you normally use to start, it can even be the Environment variable in which you already store this script in the app service settings. 

Normally I configure all this inside the Azure portal App Service Configuration section, where it says Startup command:

You can add something like this, you need to replace all variables directly here or by declaring them before in the app service configuration

wget -O /tmp/installer-wrapper.sh -q https://raw.githubusercontent.com/dynatrace-oss/cloud-snippets/main/azure/linux-app-service/oneagent-installer.sh && DT_ENDPOINT=$DT_ENDPOINT DT_API_TOKEN=$DT_API_TOKEN DT_INCLUDE=$DT_INCLUDE START_APP_CMD=$START_APP_CMD sh /tmp/installer-wrapper.sh

Best regards,

Jose

 
 

screenshot-2022-12-13-at-13-42-44-1109-8955530cdd.png

 This is the section I'm talking about.

Hi Jose,

Yes, that's the script I'm trying to figure out what to put in. In the past I have used pm2 or java there for Node and Java stack, but for Tomcat I don't get what I need to input there. Based on the MS documentation(https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/faqs-app-service-linux#what-are-the...) it seems to expect a Tomcat configuration file but not necessarily a startup command. From this blog post(https://techcommunity.microsoft.com/t5/apps-on-azure-blog/customize-tomcat-configuration-in-linux-ap...) I gathered that you can use the tomcat startup script to make changes to the server, but I didn't see any startup command there like ./catalina.sh etc.

With

START_APP_CMD= /usr/local/tomcat/bin/startup.sh

I manage to get the OA to monitor the tomcat process.

Great! I was about to suggest the same.

If you don't see the traces yet you may need to restart again (double restart).

Good luck!

Featured Posts