Rough Book

random musings of just another computer nerd

Getting artifactory running on Ubuntu 18.04

I was trying to get the Artifactory OSS 6.3.3 running on Ubuntu 18.04 and ran into issues described in RTFACT-16909. The issue is that there are systemd changes in 18.04 that make the handling of PID files much stricter. When Artifactory starts up as a service, systemd runs /opt/jfrog/artifactory/bin/artifactoryManage.sh as root. But the script then starts up Tomcat as the artifactory user. The PID of the Tomcat process is then written to the PID file in /var/opt/jfrog/run/artifactory.pid. When control comes back to systemd, it sees that the PID file is not owned by root and refuses to deal with it. The errors look like this:

Sep 26 19:04:33 ip-172-31-41-254 artifactoryManage.sh[13784]: Max number of open files: 1024
Sep 26 19:04:33 ip-172-31-41-254 artifactoryManage.sh[13784]: Using ARTIFACTORY_HOME: /var/opt/jfrog/artifactory
Sep 26 19:04:33 ip-172-31-41-254 artifactoryManage.sh[13784]: Using ARTIFACTORY_PID: /var/opt/jfrog/run/artifactory.pid
Sep 26 19:04:33 ip-172-31-41-254 artifactoryManage.sh[13784]: Tomcat started.
Sep 26 19:05:02 ip-172-31-41-254 systemd[1]: Started Session 211 of user ubuntu.
Sep 26 19:05:12 ip-172-31-41-254 artifactoryManage.sh[13784]: Artifactory Tomcat started in normal mode
Sep 26 19:05:12 ip-172-31-41-254 systemd[1]: artifactory.service: New main PID 13844 does not belong to service, and PID file is not owned by root. Refusing.
Sep 26 19:05:12 ip-172-31-41-254 systemd[1]: artifactory.service: New main PID 13844 does not belong to service, and PID file is not owned by root. Refusing.
Sep 26 19:05:12 ip-172-31-41-254 systemd[1]: artifactory.service: Failed with result 'protocol'.
Sep 26 19:05:12 ip-172-31-41-254 systemd[1]: Failed to start Setup Systemd script for Artifactory in Tomcat Servlet Engine.
Sep 26 19:05:17 ip-172-31-41-254 systemd[1]: artifactory.service: Service hold-off time over, scheduling restart.
Sep 26 19:05:17 ip-172-31-41-254 systemd[1]: artifactory.service: Scheduled restart job, restart counter is at 201.
Sep 26 19:05:17 ip-172-31-41-254 systemd[1]: Stopped Setup Systemd script for Artifactory in Tomcat Servlet Engine.
Sep 26 19:05:17 ip-172-31-41-254 systemd[1]: Starting Setup Systemd script for Artifactory in Tomcat Servlet Engine...
Sep 26 19:05:17 ip-172-31-41-254 artifactoryManage.sh[14254]: found java executable in JAVA_HOME
Sep 26 19:05:17 ip-172-31-41-254 artifactoryManage.sh[14254]: Artifactory Tomcat already started
Sep 26 19:05:17 ip-172-31-41-254 systemd[1]: artifactory.service: Can't open PID file /var/opt/jfrog/run/artifactory.pid (yet?) after start: No such file or directory
Sep 26 19:05:17 ip-172-31-41-254 systemd[1]: artifactory.service: Failed with result 'protocol'.
Sep 26 19:05:17 ip-172-31-41-254 systemd[1]: Failed to start Setup Systemd script for Artifactory in Tomcat Servlet Engine.
Sep 26 19:05:23 ip-172-31-41-254 systemd[1]: artifactory.service: Service hold-off time over, scheduling restart.
Sep 26 19:05:23 ip-172-31-41-254 systemd[1]: artifactory.service: Scheduled restart job, restart counter is at 202.
Sep 26 19:05:23 ip-172-31-41-254 systemd[1]: Stopped Setup Systemd script for Artifactory in Tomcat Servlet Engine.

To work around this issue, you have to do the following. First, in /lib/systemd/system/artifactory.service add the following lines under the [Service] section:

User=artifactory   # change if your artifactory user is different
Group=artifactory  # change if your artifactory group is different

This will now run artifactoryManage.sh as the artifactory user. But the script assumes that it is to be run as root, and so there are some changes you will need to make. First, the script uses ulimit to change the limits on the number of open files. This will fail because the artifactory user will not have permissions to set the hard limit. You can get around that by adding the following to /etc/security/limits.conf:

artifactory soft nofile 32000  # change if your artifactory user is different
artifactory hard nofile 32000  # change if your artifactory user is different

Note: The actual numbers may be different for your system. To find out what they are, manually run artifactoryManage.sh start as the artifactory user before you make the above changes. The script should spit out lines similar to the ones above.

Finally, you will need to change some lines in /opt/jfrog/artifactory/bin/artifactoryManage.sh. In the snippet below, the commented-out line is the code as it originally appears and the modification is just below that:

#su -s "/bin/sh" ${ARTIFACTORY_USER} -c "${replicatorScript} start"
${replicatorScript} start

...

#su -s "/bin/sh" ${ARTIFACTORY_USER} -c "${replicatorScript} start"
${replicatorScript} stop

...

#su -s "/bin/sh" $ARTIFACTORY_USER -c "export JAVA_HOME='$JAVA_HOME'; $TOMCAT_HOME/bin/startup.sh"
$TOMCAT_HOME/bin/startup.sh

...

#su -s "/bin/sh" $ARTIFACTORY_USER -c "export JAVA_HOME='$JAVA_HOME'; $TOMCAT_HOME/bin/shutdown.sh"
$TOMCAT_HOME/bin/shutdown.sh

Note: I also made these exact changes to /opt/jfrog/artifactory/misc/service/artifactory for the sake of consistency, but I have not verified that it is strictly necessary.

We have to make these changes because artifactoryManage.sh is being run as the artifactory user now and so there is no need to explicitly run the other scripts as the same user. Once you make these changes, you should be able to start artifactory via systemctl start artifactory.service successfully.

I love Arizona sunrises. 
#nofilter #az #arizonasunrise #azmorning #arizonamornings #sunrise #scenery #nature #morning #desertsunrise #arizona
I love Arizona sunrises. #nofilter #az #arizonasunrise #azmorning #arizonamornings #sunrise #scenery #nature #morning #desertsunrise #arizona
I like to play in the sprinklers!

#borador #boradorsofinstagram #bordercollie #labrador #labradorsofinstagram #bordercolliesofinstagram #muttsofinstagram #mutt #shelterdog #shelterdogsofinstagram #rescuedog #rescuedogsofinstagram #petphotography #petsofinstagram #pet #doggo #dog #pixel2portrait #pixel2xlphotography
I like to play in the sprinklers! #borador #boradorsofinstagram #bordercollie #labrador #labradorsofinstagram #bordercolliesofinstagram #muttsofinstagram #mutt #shelterdog #shelterdogsofinstagram #rescuedog #rescuedogsofinstagram #petphotography #petsofinstagram #pet #doggo #dog #pixel2portrait #pixel2xlphotography

Silly Bear rolling in the grass! #chowtriever #chowchow #flatcoatedretriever #retriever #doggo #dogsofinstagram #mutt #muttsofinstagram #shelterdogsofinstagram #shelterdog #rescuedog #rescuedogsofinstagram #dog #petsofinstagram #silly #pet #fluffy #floof #fluffy

Silly Bear rolling in the grass!

#chowtriever #chowchow #flatcoatedretriever #retriever #doggo #dogsofinstagram #mutt #muttsofinstagram #shelterdogsofinstagram #shelterdog #rescuedog #rescuedogsofinstagram #dog #petsofinstagram #silly #pet #fluffy #floof #fluffy

Sailboat through the trees. 
#sailboat #sanfranciscobay #sailing #boating #sf #sanfrancisco #bayarea #boats #boating #sailboats #photography #photographer #amateurphotography #amateurphotographer #sceneryphotography #scenery #ocean #blue
Sailboat through the trees. #sailboat #sanfranciscobay #sailing #boating #sf #sanfrancisco #bayarea #boats #boating #sailboats #photography #photographer #amateurphotography #amateurphotographer #sceneryphotography #scenery #ocean #blue
My baby niece Mila. 
#baby #portrait #pixel2portrait #pixel2xlportraitmode #pixel2xlphotography #cute #goldenhour #photography #amateurphotography #photographer #amateurphotographer
My baby niece Mila. #baby #portrait #pixel2portrait #pixel2xlportraitmode #pixel2xlphotography #cute #goldenhour #photography #amateurphotography #photographer #amateurphotographer
I'm like a little bear. 
#chowtriever #chowchow #flatcoatedretriever #retriever #doggo #dogsofinstagram #mutt #muttsofinstagram #shelterdogsofinstagram #shelterdog #rescuedog #rescuedogsofinstagram #dog #petphotography #petsofinstagram #pixel2portrait #pixel2xlphotography #pet #fluffy #floof #fluffy
I’m like a little bear. #chowtriever #chowchow #flatcoatedretriever #retriever #doggo #dogsofinstagram #mutt #muttsofinstagram #shelterdogsofinstagram #shelterdog #rescuedog #rescuedogsofinstagram #dog #petphotography #petsofinstagram #pixel2portrait #pixel2xlphotography #pet #fluffy #floof #fluffy
Painting with Lights at the Desert Botanical Garden Flashlight Tour.

#flashlighttour #desertbotanicalgarden #phoenix
Painting with Lights at the Desert Botanical Garden Flashlight Tour. #flashlighttour #desertbotanicalgarden #phoenix
Evening at the Desert Botanical Garden. 
#landscape #silhouette #desert #desertbotanicalgarden #sonorandesert #evening #arizona #amateurphotographer #amateurphotography #photographer #photography #pixel2xlphotography
Evening at the Desert Botanical Garden. #landscape #silhouette #desert #desertbotanicalgarden #sonorandesert #evening #arizona #amateurphotographer #amateurphotography #photographer #photography #pixel2xlphotography
Yesterday was the last night of the 2018 Pat Tillman Leadership Summit. Following the tradition set by the class of 2016, we took over all of Brando's Speakeasy and sang karaoke till the wee hours of the morning. I had to wake up at 4 to catch an early flight, but that didn't matter!

The past few days at the summit have been amazing. I feel humbled and honored to be among such accomplished individuals, and have to keep pinching myself to make sure that this isn't a dream. Meeting a lot of new people at the same time isn't an easy thing for me because I'm an introvert. But this wasn't an issue here... I met people just like me -- people who are intensely passionate about something in their lives and want to change the world by following that passion. People who will entertain your nerdy notions, who will enthusiastically engage you in conversation about some obscure bit of interesting trivia, who won't laugh at you or roll their eyes. I really felt like I belonged. 
I'm honored to be part of this family and I'm definitely looking forward to next year's summit!

#pattillmanfoundation #pattillmanleadershipsummit #ptls2018 #2018tillmanscholars
Yesterday was the last night of the 2018 Pat Tillman Leadership Summit. Following the tradition set by the class of 2016, we took over all of Brando’s Speakeasy and sang karaoke till the wee hours of the morning. I had to wake up at 4 to catch an early flight, but that didn’t matter! The […]
All original content on these pages is fingerprinted and certified by Digiprove
%d bloggers like this: