[EdLUG] How can I troubleshoot misbehaving java application

Tahir Hafiz tahir.hafiz at gmail.com
Tue Dec 8 18:49:14 UTC 2020


Hello Tai and everyone,

Yes, I think I understand why a little more now - the springboot app
that as it comes down (from our pipeline) is set-up as sytemd service
- it has a systemd service file.

But the line in the systemd service file that starts the app is called
ExecStart.
Now ExecStart passes a https_proxy to the running java SpringBoot
application and I think that proxy is not consumed by the SpringBoot
app because of SystemD not pushing it into the app.

It’s a line like this in the systemd service file:ExecStart=/bin/java
-Xmx1200m -Dhttp.nonProxyHosts=*.service.nexte-Dhttps.proxyHost=internal-outbounds-nat-1.eu-west-2.elb.amazoneaws.com
-Dhttps.proxyPort=3128 -Dlogging.config=/opt/my-api/config/logback.xml
-jar /opt/my-api/my-api-6.1.jar

So whenever it pipelines down, or we do a systemctl stop/start my-api
it crashes. But if we do it manually without systemd and pass in the
proxy:
java Dhttps.proxyHost=xyz -jar *.jar, it does work and picks up the
proxy settings and is able to go outbound on https as it is run up.

Any ideas how to construct the ExecStart line so systemd will pass on
the proxy variables?

Also, how can I log into different server boxes and run these two
commands in a shell but with some kind of nohup option (or similar) so
the process won’t crash if I get timed out (kicked out) from the
shells:
1. java --jar *.jar
2. npm run

Basically I want to log-in to the servers and have these run forever
or at least for like 9hrs. Even if I get kicked out of the shell.
Thanks everyone and Tai!

Cheers,
Tahir

On Tue, Dec 8, 2020 at 2:59 PM Tai Kedzierski <dch.tai at gmail.com> wrote:
>
> Hi Tahir
>
> The way I understand your command, it looks like you can pass the proxy string in the command arguments at Java level, is the command as-run in CI actually doing that?
>
> If it's in environment variables, 1/ is that variable exported, and 2/ Does Java/your app actually expressly respect that environment variable?
>
> http_proxy is just a variable as far as I know - it should be up to applications to know/care whether they implement its use at all.
>
>
> ===
> Tai Kedzierski
>
> EdLUG Maintainer: https://edlug.gitlab.io/
>
> Edinburgh Language Meetup Organiser
> https://www.meetup.com/Edinburgh-Language-Exchange-Meetup-Group/
>
> Open Source Free Software is a matter of liberty, not price.
> https://www.fsf.org/about/what-is-free-software
>
>
>
> On Mon, 7 Dec 2020 at 18:35, Tahir Hafiz <tahir.hafiz at gmail.com> wrote:
>>
>> Dear All,
>>
>> I am trying to run up a java application on a Centos 7 CIS Hardened
>> image. The application when using a gitlab-ci pipeline (gitlab ci,
>> ansible, aws), does not seem to take up the https_proxy being passed
>> to it. systemctl status shows the application bouncing up and down. I
>> have tried switching off SELinux.
>>
>> If I run the application manually on the ec2 instance by the user
>> www-data which owns the application directory:
>> java -Dhttps.proxyHost=internal-outbound-nat-xyxzamazonaws
>> -Dhttps.proxyPort=3128 -jar /opt/*.jar
>>
>> Then the application is able to start successfully.
>>
>> But it won't start up successfully and times out on trying to reach
>> the proxy when trying it from the pipeline because I think java is
>> unable to take up the proxy settings.
>>
>> Any clues as to what might be happening?  What log files can I look at?
>> Can systemd, journald help me here figure out what is happening? The
>> application log for the app appears empty.
>>
>> Cheers,
>> Tahir
>>
>> --
>> EdLUG mailing list
>> EdLUG at mailman.lug.org.uk
>> https://lists.edlug.org.uk/mailman/listinfo/edlug
>
> --
> EdLUG mailing list
> EdLUG at mailman.lug.org.uk
> https://lists.edlug.org.uk/mailman/listinfo/edlug



More information about the EdLUG mailing list