Difference between revisions of "Running CTP as a Linux Service"

From MircWiki
Jump to navigation Jump to search
 
(45 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is most easily done using [http://www.ubuntu.com/ Ubuntu]
+
=== A word on Linux ===
If you are using virtual machines I recommend [http://turnkeylinux
 
  
 +
To be accurate, the term Linux properly only refers to the Operating System kernel developed by Linus Torvalds. Linux ''distributions'' are then built on that kernel. Not all distrbutions are built the same way. There are two main families: those that use the RPM package system (Redhat, Fedora, CentOS, Scientific Linux, Suse, etc) and those that use the .Deb package systems (Debian, Ubuntu, Kubuntu, etc).
  
== Instructions for installing the latest CTP/MIRC-Zn in Ubuntu ==
+
Those families further differ in how they manage system services. The .Deb family largely follows BSD style init scripts. The RPM family follows AT&T System V init scripts. To control CTP as a service (start, stop, get status) on your Linux distribution you must choose the proper tool from the two options below.
  
===Choosing Ubuntu Desktop or Server?===
+
=== Init Scripts for Redhat (or similar) System V systems ===
* Ubuntu Server
 
** Makes more sense - MIRC is a web service after all.
 
** Will be leaner and faster.
 
** Can run on a headless server or virtual machine.
 
* Ubuntu Desktop
 
** Easier (very easy) if you're new to Linux.
 
** May be very slightly slower but on modern hardware you are unlikely to notice the difference.
 
** You can just do part 1 and then part 2 straight away (X-forwarding is not an issue).
 
  
===How to cut and paste the script below into a file and execute it===
+
The <b><tt>CTP/linux</tt></b> folder of the CTP installation now includes a new file called <b><tt>ctpService-red.sh</tt></b>. This file is internally documented, but in brief you must confirm that the variable settings in it match your environment settings. The simplest way to to this is the following. From the command line verify that the following will start CTP:
* Open an editor
 
nano ./install-MIRCn.sh
 
* Cut and paste the code from the box below
 
* Save the file and exit
 
ctrl-O and then hit enter
 
ctrl-X
 
* Make it executable
 
chmod 777 ./install-MIRCn.sh
 
* Run it
 
./install-MIRCn.sh
 
  
 +
<pre>
 +
java -jar Runner.jar
 +
</pre>
  
** You will need to ssh in to the server with X-fowarding when you run the MIRC-Installer.jar file
+
If the above works, then we need only assure that the JAVA_HOME, JAVA_BIN, CLASSPATH and CTP_HOME settings in the script match the output of the "env" command. Once that is confirmed, do the following steps (where CTP_HOME is the true location of the CTP root folder):
** The script below will talk you through it.
 
*** From a linux desktop to a linux server this is ssh -x username@host
 
*** From a mac to a linux server this is ssh -Y username@host
 
*** From a windows box you will need Putty and Xming X Server for MS Windows (google them).
 
  
===The script===
+
<pre>
You can cut and paste each line to the command prompt or just put the whole thing into a file and execute it.
+
ln -s /CTP_HOME/linux/ctpService-red.sh /etc/init.d/ctpService
This script does the following things:
+
chkconfig --add /etc/init.d/ctpService
# Check which chipset you're running
+
</pre>
# Enable the ubuntu partner repo (to get Oracle Java)
+
 
# Answers the Java installation questions in advance
+
This will install CTP as a service and it will autostart when the Linux distribution boots. All the normal service commands are now available:
# Installs SunJava and a few other necessary applications
+
 
# Downloads the appropriate JAI ImageIO and fixes the inherent problem in the Linux release
+
<pre>
# Installs JAI ImageIO
+
/sbin/service ctpService start/stop/restart/status
# Downloads the latest version of MIRC-Zn
+
</pre>
# Writes an upstart script (so that CTP/MIRC will be run as a service automatically)
+
 
# Installs RSNA MIRC
+
''Any questions or comments please email langer.steve@mayo.edu - Steve Langer.''
# If you are logged in without X11 or X-forwarding this script will tell you and help you fix it.
+
 
## Lightweight installations of Ubutnu (eg jeos or TurnkeyLinux core) don't have the libraries for X-forwarding. This script will install them.
+
=== Init scripts for Ubunutu (or similar) BSD systems ===
 +
 
 +
* This is a small part of what the script described in [[Install or upgrade RSNA TFS (previously known as MIRC) on Ubuntu Linux]] will do automatically for you.
 +
* If you want to install MIRC on a Linux machine it is recommended you read the article above.
 +
* If you are here because you want to run an existing Linux installation of CTP or MIRC as a service, continue reading.
 +
 
 +
 
 +
''' 3.1 Using an UpStart script  
 +
 
 +
Ubuntu and many other Linux distros use UpStart to run services.
 +
The below example assumes CTP is installed at
 +
 
 +
/usr/share/CTP/
 +
 
 +
You can modify it to suit a different locations.
 
   
 
   
  #!/bin/bash
+
Cut and paste the below code
 +
 
 +
description "CTP Service on Linux"
 +
author "Tim Phillips <timothy.john.phillips@gmail.com>"
 
   
 
   
  #check which chipset we're using
+
start on (local-filesystems and net-device-up IFACE!=lo)
  case $(arch) in
+
stop on stopping network-services
  i686)
 
  CHIP=i586
 
  ;;
 
  x86_64)
 
  CHIP=amd64
 
  ;;
 
  *)
 
  ;;
 
  esac
 
 
   
 
   
  # partner repo
+
respawn
  echo deb http://archive.canonical.com/ lucid partner >>/etc/apt/sources.list.d/partner.list
 
  apt-get update
 
 
   
 
   
  # preset the java answers:
+
expect fork
  debconf-set-selections << END
 
  sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true
 
  sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true
 
  sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true
 
  END
 
 
   
 
   
  # packages installed:
+
  script
  apt-get install -y acpid htop unzip xauth libxtst6 sun-java6-jdk
+
  cd /usr/share/CTP/
   
+
  java -jar ./CTP-runner.jar
  # get jai binary
+
  end script
  wget http://download.java.net/media/jai-imageio/builds/release/1.1/jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
+
 
   
+
into a file named
  # make it executable
+
 
  chmod 777 ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
+
  /etc/init/CTP.conf
+
 
  # fix an inherent flaw in the file (thanks to JGrass for this)
+
 
  sed -i 's/+215/-n+215/' ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
+
''' 3.2 Commands to control the CTP service
+
 
  # put it in the jdk folder
+
To start CTP (it will start automatically when the machine boots)
  mv ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin /usr/lib/jvm/java-6-sun/
+
  start CTP
   
+
To stop CTP:
  # execute the installer
+
  stop CTP
  cd /usr/lib/jvm/java-6-sun/
+
To check if CTP is running:
  ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
+
  status CTP
   
+
To restart CTP:
  # go back to the home folder
+
  restart CTP
  cd -
+
 
+
''Any questions or comments please email timothy.john.phillips@gmail.com - Tim Phillips.''
  # get MIRC installer
 
  wget http://mirc.rsna.org/MIRC2/MIRC-installer.jar
 
   
 
  # make an upstart script
 
  cat > /etc/init/MIRC-Zn.conf <<DELIM
 
  description "MIRC Zn (CTP plugin not Tomcat)"
 
  author "Tim Phillips <timothy.john.phillips@gmail.com>"
 
 
  start on (local-filesystems and net-device-up IFACE!=lo)
 
  stop on stopping network-services
 
   
 
  respawn
 
   
 
  expect fork
 
   
 
  script
 
  cd /usr/share/CTP/
 
  java -jar ./CTP-runner.jar
 
  end script
 
  DELIM
 
   
 
  echo 'Now the RSNA installer will run'
 
  echo 'You will be asked to choose a folder to install CTP/MIRC into'
 
  echo 'It is very important that you type in /usr/share'
 
  echo 'Do not accept the default folder that it will offer you'
 
  echo 'hit enter to continue'
 
  read dummy
 
 
  if [[ $(java -jar ./MIRC-installer.jar 2>&1 | grep X11) ]]
 
  then
 
  # have to re-login with X forwarding
 
  echo 'X-forwarding is required for the MIRC installer'
 
  echo 'logout, type in exit and hit enter'
 
  echo 'and then login again from a machine with a screen....'
 
  echo 'From a mac: ssh -Y user@host'
 
  echo 'From a linux desktop: ssh -X user@host'
 
  echo 'If you are using windows you will need PuTTy and Xming (google them)'
 
  echo -e
 
  echo 'When you have logged in again type in:'
 
  echo 'java -jar ./MIRC-installer.jar'
 
  echo 'when prompted remember to install CTP/MIRC into /usr/share'
 
  echo 'when its finished - reboot and it should all be running'
 
  else
 
  echo 'finished - reboot and it should all be running'
 
  echo 'point your browser to this server and have a look'
 

Latest revision as of 12:21, 13 August 2013

1 A word on Linux

To be accurate, the term Linux properly only refers to the Operating System kernel developed by Linus Torvalds. Linux distributions are then built on that kernel. Not all distrbutions are built the same way. There are two main families: those that use the RPM package system (Redhat, Fedora, CentOS, Scientific Linux, Suse, etc) and those that use the .Deb package systems (Debian, Ubuntu, Kubuntu, etc).

Those families further differ in how they manage system services. The .Deb family largely follows BSD style init scripts. The RPM family follows AT&T System V init scripts. To control CTP as a service (start, stop, get status) on your Linux distribution you must choose the proper tool from the two options below.

2 Init Scripts for Redhat (or similar) System V systems

The CTP/linux folder of the CTP installation now includes a new file called ctpService-red.sh. This file is internally documented, but in brief you must confirm that the variable settings in it match your environment settings. The simplest way to to this is the following. From the command line verify that the following will start CTP:

java -jar Runner.jar

If the above works, then we need only assure that the JAVA_HOME, JAVA_BIN, CLASSPATH and CTP_HOME settings in the script match the output of the "env" command. Once that is confirmed, do the following steps (where CTP_HOME is the true location of the CTP root folder):

ln -s /CTP_HOME/linux/ctpService-red.sh /etc/init.d/ctpService
chkconfig --add /etc/init.d/ctpService

This will install CTP as a service and it will autostart when the Linux distribution boots. All the normal service commands are now available:

/sbin/service ctpService start/stop/restart/status

Any questions or comments please email langer.steve@mayo.edu - Steve Langer.

3 Init scripts for Ubunutu (or similar) BSD systems

  • This is a small part of what the script described in Install or upgrade RSNA TFS (previously known as MIRC) on Ubuntu Linux will do automatically for you.
  • If you want to install MIRC on a Linux machine it is recommended you read the article above.
  • If you are here because you want to run an existing Linux installation of CTP or MIRC as a service, continue reading.


3.1 Using an UpStart script

Ubuntu and many other Linux distros use UpStart to run services. The below example assumes CTP is installed at

/usr/share/CTP/

You can modify it to suit a different locations.

Cut and paste the below code

description "CTP Service on Linux"
author "Tim Phillips <timothy.john.phillips@gmail.com>"

start on (local-filesystems and net-device-up IFACE!=lo)
stop on stopping network-services

respawn

expect fork

script
cd /usr/share/CTP/
java -jar ./CTP-runner.jar
end script

into a file named

/etc/init/CTP.conf


3.2 Commands to control the CTP service

To start CTP (it will start automatically when the machine boots)

start CTP

To stop CTP:

stop CTP

To check if CTP is running:

status CTP

To restart CTP:

restart CTP

Any questions or comments please email timothy.john.phillips@gmail.com - Tim Phillips.