Skip to end of metadata
Go to start of metadata
Table of Contents

Note: This space is for Artifactory 2.0.
Take me to the latest version!

Unix

When using Unix, it is possible to install Artifactory as a Unix service or run it manually.
Before you install is recommended you first verify your current environment by running artifactoryctl check under the $ARTIFACTORY_HOME/bin folder (this script is, in fact, a customized Jetty init script).

Installing Artifactory as Linux Service

Introduction

Artifactory is packaged with a complete install script that can be used to install it as a Unix service running under a custom user and using the standard Unix directories.

Installing

To setup Artifactory correctly as a Linux service run, as root, the $ARTIFACTORY_HOME/bin/install.sh script.

Here is the main information about what this script is doing:

User creation

Creates a user named "artifactory" ($ARTIFACTORY_USER) by default. You can change the default user by editing the $ARTIFACTORY_USER value in /etc/artifactory/default. The install script accepts the user name as its first and only parameter.

etc config

Creates the folder /etc/artifactory, copies the configuration files there and creates a soft link in $ARTIFACTORY_HOME/etc

etc default

Creates the file /etc/artifactory/default that contains the main environment variables needed for artifactory to run: JAVA_HOME, ARTIFACTORY_USER, ARTIFACTORY_HOME, JAVA_OPTIONS,...
The /etc/artifactory/default is included at the top of artifactoryctl and so can include whatever you wish.
NOTE: The default max memory is 1GB

init.d

It copies the file artifactoryctl to /etc/init.d/artifactory

Logs folder

Creates /var/log/artifactory folder, makes it writable for the user ARTIFACTORY_USER and creates a soft link $ARTIFACTORY_HOME/logs.

Backup folder

Creates the folder $ARTIFACTORY_HOME/backup, so you will need to create a link if you wish this folder to point to somewhere else (like /var/backup/artifactory for example). The script makes $ARTIFACTORY_HOME/backup writable for the user ARTIFACTORY_USER.

Data folder

Create the folder $ARTIFACTORY_HOME/data, so you will need to create a link if you wish this folder to point to somewhere else. The script will make it writable for the user ARTIFACTORY_USER.

chkconfig calls

The script calls add, list (you can see the output), then activate the Artifactory service

After running the script successfully you can test the installation by running: service artifactory check or /etc/init.d/artifactory check

And if everything is OK, start artifactory with:

service artifactory start

or

/etc/init.d/artifactory start

You can then check the Artifactory log with:

tail \-f $ARTIFACTORY_HOME/logs/artifactory.log

Normally Artifactory will be started as root (when running as a service) and will su internally to the $ARTIFACTORY_USER user. If the $ARTIFACTORY_USER is undefined Artifactory will run as the current user, which is not recommended, especially if the current user is root, due to security considerations.

Running Artifactory Manually on Unix

You can run artifactory manually with artifactory.sh directly to see its behavior. The console will be locked on artifactory process and you can stop it cleanly with crtl+c.

You can also try executing

artifactoryctl check|start|stop

to directly run Artifactory as a daemon process, using the environment variable of the shell you are currently in.

  • No labels

1 Comment

  1. If you're using Gentoo Linux or anything with a similar set of startup tools (start-stop-daemon, runscript, ebegin, eend, etc.) I cooked up this script which works nicely with this environment:

    #!/sbin/runscript
    # Installed in /etc/init.d/artifactory
    
    export JAVA_HOME=/etc/java-config-2/current-system-vm
    export PATH=$JAVA_HOME/bin:$PATH
    DESC="Artifactory Maven Artifact Server"
    NAME=artifactory
    PIDFILE=/var/run/$NAME.pid
    RUN_AS=artifact
    ARTIFACTORY_HOME=/opt/artifact/artifactory
    COMMAND=$ARTIFACTORY_HOME/bin/artifactory.init
    ARGS="$ARTIFACTORY_HOME/etc/jetty.xml"
    LOGFILE="$ARTIFACTORY_HOME/logs/consoleout.log"
    
    depend() {
    	use net
    	after logger
    }
    
    start() {
    	ebegin "Starting $DESC"
    	start-stop-daemon --start --verbose --background --make-pidfile --pidfile $PIDFILE\
    	           --chdir $ARTIFACTORY_HOME --chuid $RUN_AS --exec $COMMAND -- $ARGS > $LOGFILE 2>&1
    	eend $?
    }
    
    stop() {
    	ebegin "Stopping $DESC"
    	start-stop-daemon --stop --quiet --pidfile $PIDFILE
    
    	if [ -e $PIDFILE ]
    	then
    	  rm $PIDFILE
    	fi
    
    	eend $?
    }
    

    Before installing, I logged in as root and ran useradd to create a user called artifact then whipped up a wrapper script to invoke Artifactory's install.sh (from the Artifactory .zip download) which set the necessary environment variables:

    #!/bin/sh
    export ARTIFACTORY_HOME=/opt/artifact/artifactory
    export JETTY_CONF=
    export ARTIFACTORY_USER=artifact
    export ARTIFACTORY_RUN=/tmp
    export ARTIFACTORY_PID=/tmp/artifactory.pid
    export ARTIFACTORY_CONSOLE=/opt/artifact/artifactory/logs/consoleout.log
    export JETTY_PORT=
    export JETTY_ARGS=
    export CONFIGS=/opt/artifact/artifactory/etc/jetty.xml
    export JAVA_OPTIONS=-Djava.awt.headless=true
    export JAVA=/etc/java-config-2/current-system-vm/bin/java
    export CLASSPATH=
    export RUN_CMD="/opt/artifact/artifactory/bin/artifactory.init /opt/artifact/artifactory/etc/jetty.xml"
    
    $ARTIFACTORY_HOME/bin/install.sh
    

    Then I registered the script to invoke itself in the default run level:

    # rc-config add artifactory default
    

    Without needing to reboot I then started the script:

    # rc-config start artifactory
    

    Then it should show up in ps:

    # ps -fu artifact
    UID        PID  PPID  C STIME TTY          TIME CMD
    artifact 14156 14078  0 12:42 pts/1    00:00:00 su - artifact
    artifact 14162 14156  0 12:42 pts/1    00:00:01 bash
    artifact 20243     1  2 15:58 ?        00:00:56 /etc/java-config-2/current-system-vm/bin/java -server -Xms300m -Xmx1g -Xss256k -XX:PermSize=128m -XX:MaxPermSize=128m -Djava.awt.headless=true -Djetty.home=/opt/artifact/artifactory -Dartifactory.home=/opt/artifact/artifactory -cp /opt/artifact/artifactory/artifactory.jar:/opt/artifact/artifactory/lib/artifactory-config-2.0.7.jar:/opt/artifact/artifactory/lib/commons-io-1.4.jar:/opt/artifact/artifactory/lib/jetty-6.1.14.jar:/opt/artifact/artifactory/lib/jetty-ajp-6.1.14.jar:/opt/artifact/artifactory/lib/jetty-util-6.1.14.jar:/opt/artifact/artifactory/lib/logback-classic-0.9.11.jar:/opt/artifact/artifactory/lib/logback-core-0.9.11.jar:/opt/artifact/artifactory/lib/servlet-api-2.5-6.1.14.jar:/opt/artifact/artifactory/lib/slf4j-api-1.5.5.jar:/opt/artifact/artifactory/lib/wrapper.jar org.artifactory.standalone.main.Main /opt/artifact/artifactory/etc/jetty.xml
    artifact 20336 14162  0 15:58 pts/1    00:00:00 tail -f logs/artifactory.log