YouTrack Standalone 2017.1 Help

Install YouTrack JAR as a Service on Linux

This page provides two sample methods that you can use to install and run YouTrack JAR as a service on *nix-like machines:

YouTrack JAR Installation for Linux

The instructions that are provided in this setup guide have been used by the JetBrains development team to install and run YouTrack JAR in a Linux environment.

Prerequisites

To perform this installation, verify that the following prerequisites are met:

  • You have installed Oracle Java Runtime Environment 8 or later.
  • Any external hostname (proxy hostname) is resolvable from the actual host where YouTrack is installed.

Installation

The following procedure describes how to install and run YouTrack JAR as a service on Linux or another *nix-like operating system. The method for adding a startup script that is used in this setup has been tested in environments similar to the Red Hat Linux operating system.

To install the YouTrack JAR distribution as a service on Linux:

  1. Download the JAR distribution from the JetBrains website.
  2. Create a user account to run the YouTrack service. For example, youtrack. The youtrack user account manages YouTrack data and services.
    adduser youtrack --disabled-password
  3. Download the Tanuki Java Service Wrapper that is compatible with your CPU. For an Intel-based machine, use the following commands:
    cd ~youtrack wget http://wrapper.tanukisoftware.com/download/3.5.30/wrapper-linux-x86-64-3.5.30.tar.gz
  4. Extract the wrapper archive to the home directory of the service user account.

    For usability, we also recommend that you rename the wrapper directory. For example, standalone.

    tar -xzf wrapper-linux-x86-64-3.5.30.tar.gz mv wrapper-linux-x86-64-3.5.30 standalone

    The directory structure for the wrapper should be similar to the following example:

    ./standalone ./standalone/bin ./standalone/conf ./standalone/doc ./standalone/lib ./standalone/logs ./standalone/src
  5. Copy the YouTrack JAR file to the wrapper directory:
    cp youtrack-<version>.jar ~youtrack/standalone/
  6. Create a soft link to the JAR file:
    cd ~youtrack/standalone/ ln -s youtrack-<version>.jar youtrack.jar
  7. Create a system startup script in the /etc/init.d/ folder. The script is responsible for starting, stopping, and restarting YouTrack.
    • Copy the following script template: youtrack_initd.template

      This template is based on a sample startup script that is included in the wrapper distribution.

    • Change the settings in the top section of the script to reflect your system environment.
    • Save the edited template as youtrack in the /etc/init.d/ folder.
  8. Replace the configuration file of an existing wrapper ~youtrack/standalone/conf/wrapper.conf with the following configuration file: wrapper.conf

    Modify the configuration file to match your YouTrack installation.

    The wrapper.conf file includes references to the following mandatory JVM options:

    • The maximum Permanent Generation memory is set with the JVM option -XX:MaxMetaspaceSize=256m.
    • The maximum Java heap size is set with the property wrapper.java.maxmemory=1536. Do not set this property lower than 1024m or 1g.
  9. Run the wrapper to test the installation:
    /sbin/service youtrack start

    If the test is successful, the following conditions are met:

    • YouTrack starts successfully.
    • The youtrack.pid file is created in the ~youtrack/standalone/ folder.
    • The wrapper.log file is created in the ~youtrack/standalone/logs/ folder.
  10. Add the new startup script to the system startup scripts sequence:
    /sbin/chkconfig --add youtrack
  11. You can stop or restart YouTrack with the following commands:
    /sbin/service youtrack stop /sbin/service youtrack restart
  12. By default, the new YouTrack instance is configured to use TCP port 8080.

    You can change this setting in the wrapper.conf file (replace 8080 in line wrapper.app.parameter.2=8080 with the desired port value). If you run YouTrack behind a reverse proxy server, you can configure the forwarding ports on the proxy server.

After installation, you can set up YouTrack to run behind a reverse proxy server. For instructions, see Reverse Proxy Configuration.

Alternative YouTrack JAR Installation for Ubuntu 14.04+

The following setup is based on an installation guide that was provided by one of our users. This setup is configured for an environment that uses Oracle JDK 8+.

To install YouTrack from a JAR as a Service under Linux:

  1. Add a dedicated user account for YouTrack:
    sudo adduser youtrack --disabled-password
  2. Create an init.d script:
    sudo vim /etc/init.d/youtrack
  3. Paste the following code into the init.d script:
    #! /bin/sh ### BEGIN INIT INFO # Provides: youtrack # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: initscript for youtrack # Description: initscript for youtrack ### END INIT INFO export HOME=/home/youtrack set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=youtrack SCRIPT=/home/$NAME/$NAME.sh d_start() { su youtrack -l -c "$SCRIPT start" } d_stop() { su youtrack -l -c "$SCRIPT stop" } case "$1" in start) echo "Starting $NAME..." d_start ;; stop) echo "Stopping $NAME..." d_stop ;; restart|force-reload) echo "Restarting $NAME..." d_stop d_start ;; *) echo "Usage: sudo /etc/init.d/youtrack {start|stop|restart}" >&2 exit 1 ;; esac exit 0
  4. Save the file:
    • Press Esc to exit.
    • Enter :x.
    • Press Enter.
  5. Make the script file executable and register it as an init-script:
    sudo chmod +x /etc/init.d/youtrack sudo update-rc.d youtrack defaults
  6. Create a logging subdirectory:
    sudo mkdir /var/log/youtrack sudo chown youtrack:youtrack /var/log/youtrack
  7. Create a startup script:
    sudo vim /home/youtrack/youtrack.sh
  8. Paste the following code into the startup script (youtrack.sh) (modify JAVA_HOME to match your local environment):
    #! /bin/sh ### # YouTrack startup script ### export HOME=/home/youtrack export JAVA_HOME=/usr/bin/java NAME=youtrack PORT=8112 BASEDIR=/srv/www/your.domain.tld JAR=$BASEDIR/`ls -Lt $BASEDIR/*.jar | grep -o "$NAME-[^/]*.jar" | head -1` LOG=/var/log/$NAME/$NAME-$PORT.log PID=/run/$NAME/$NAME-$PORT.pid # Setup proper run environment if [ ! -d /run/$NAME ]; then mkdir /run/$NAME chown $NAME:$NAME /run/$NAME fi if [ ! -d /var/log/$NAME ]; then mkdir /var/log/$NAME chown $NAME:$NAME /var/log/$NAME fi d_start() { if [ -f $PID ]; then PID_VALUE=`cat $PID` if [ ! -z "$PID_VALUE" ]; then PID_VALUE=`ps ax | grep $PID_VALUE | grep -v grep | awk '{print $1}'` if [ ! -z "$PID_VALUE" ]; then exit 1; fi fi fi PREV_DIR=`pwd` cd $BASEDIR exec $JAVA_HOME -Xmx1g -XX:MaxMetaspaceSize=256m -jar $JAR $PORT >> $LOG 2>&1 & echo $! > $PID cd $PREV_DIR } d_stop() { if [ -f $PID ]; then PID_VALUE=`cat $PID` if [ ! -z "$PID_VALUE" ]; then PID_VALUE=`ps ax | grep $PID_VALUE | grep -v grep | awk '{print $1}'` if [ ! -z "$PID_VALUE" ]; then kill $PID_VALUE WAIT_TIME=0 while [ `ps ax | grep $PID_VALUE | grep -v grep | wc -l` -ne 0 -a "$WAIT_TIME" -lt 2 ] do sleep 1 WAIT_TIME=$(expr $WAIT_TIME + 1) done if [ `ps ax | grep $PID_VALUE | grep -v grep | wc -l` -ne 0 ]; then WAIT_TIME=0 while [ `ps ax | grep $PID_VALUE | grep -v grep | wc -l` -ne 0 -a "$WAIT_TIME" -lt 15 ] do sleep 1 WAIT_TIME=$(expr $WAIT_TIME + 1) done echo fi if [ `ps ax | grep $PID_VALUE | grep -v grep | wc -l` -ne 0 ]; then kill -9 $PID_VALUE fi fi fi rm -f $PID fi } case "$1" in start) d_start ;; stop) d_stop ;; restart|force-reload) d_stop d_start ;; *) echo "Usage: $0 {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0
  9. Save the file:
    • Press Esc to exit.
    • Enter :x.
    • Press Enter.
  10. Change the owner to the YouTrack user account and make the script file executable:
    sudo chown youtrack:youtrack /home/youtrack/youtrack.sh sudo chmod +x /home/youtrack/youtrack.sh
  11. Download the latest YouTrack JAR package (replace <version> with the current version, accordingly):
    wget http://download.jetbrains.com/charisma/youtrack-<version>.jar –P /home/youtrack sudo chown youtrack:youtrack /home/youtrack/youtrack-<version>.jar
  12. Start YouTrack:
    sudo service youtrack start

To Update Your YouTrack Installation:

Updating YouTrack is pretty simple. You just need to re-execute the commands from step 12 above, remove the old JAR file, and restart YouTrack.

For convenience, put YouTrack into maintenance mode before you run these commands to update the service.

wget http://download.jetbrains.com/charisma/youtrack-<version>.jar –P /home/youtrack sudo chown youtrack:youtrack /home/youtrack/youtrack-<version>.jar sudo rm –f /home/youtrack/youtrack-<OLD-version>.jar sudo service youtrack restart
Last modified: 18 April 2017