Difference between revisions of "Running CTP as a Linux Service"
Tim phillips (talk | contribs) |
|||
(45 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 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. | |
− | === | + | === Init Scripts for Redhat (or similar) System V systems === |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | 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: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | <pre> | ||
+ | java -jar Runner.jar | ||
+ | </pre> | ||
− | + | 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): | |
− | |||
− | |||
− | |||
− | |||
− | + | <pre> | |
− | + | ln -s /CTP_HOME/linux/ctpService-red.sh /etc/init.d/ctpService | |
− | + | chkconfig --add /etc/init.d/ctpService | |
− | + | </pre> | |
− | + | ||
− | + | This will install CTP as a service and it will autostart when the Linux distribution boots. All the normal service commands are now available: | |
− | + | ||
− | + | <pre> | |
− | + | /sbin/service ctpService start/stop/restart/status | |
− | + | </pre> | |
− | + | ||
− | + | ''Any questions or comments please email langer.steve@mayo.edu - Steve Langer.'' | |
− | + | ||
− | + | === 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.'' | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
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.