Installing CommandLine as a service

Talend Data Integration Installation Guide for Linux

EnrichVersion
6.3
EnrichProdName
Talend Data Integration
task
Installation and Upgrade
EnrichPlatform
Talend Administration Center
Talend Activity Monitoring Console
Talend Data Stewardship
Talend JobServer
Talend Artifact Repository
Talend Data Preparation
Talend Installer
Talend Project Audit
Talend Studio
Talend CommandLine
Talend Log Server
Talend Runtime

Installing CommandLine as a service on Ubuntu

  1. Create an executable from which commandline can be run in the directory /usr/bin.

    To do this, you need to create two files, commandline_start and commandline_stop containing the following:

    For commandline_start:

    #!/bin/sh
    cd <CommandLinePath>
    nohup sh commandline-linux.sh&

    Warning

    The path <CommandLinePath> should be absolute.

    For commandline_stop:

    #!/bin/sh
    (echo stopServer ; sleep 2) | telnet localhost 8002
  2. Ensure that the two files above are executable. To do this, you can execute the two commands below in the /usr/bin directory:

    # chmod +x /usr/bin/commandline_start
    
    # chmod +x /usr/bin/commandline_stop

  3. Paste the sh file: /<CommandLinePath> /addons/scripts/talend_commandline into the directory: /etc/init.d in order to create the service related to the two executables above.

  4. Make the file executable using:

    # chmod +x /etc/init.d/talend_commandline_commandline

  5. Execute the following command:

    # update-rc.d talend_commandline_commandline defaults 60

Now you have created the service, related to the two executable files commandline_start and commandline_stop.

Installing the service on RedHat/CentOS 7 Systems

All the following commands have to be executed with super-user privileges.

  1. Create the service file with the following command:

    touch /etc/systemd/system/Talend-CommandLine.service

  2. Assign the relevant rights to the file you created:

    chmod 664 /etc/systemd/system/Talend-CommandLine.service

  3. Paste the following content in the file while adapting it to your configuration:

    [Unit]
    Description=Talend CommandLine Service
    After=network.target
    [Service]
    WorkingDirectory=<CommandLinePath>
    ExecStart=/bin/bash commandline-linux_x86_64.sh start
    Type=simple
    [Install]
    WantedBy=default.target
  4. Reload the service daemon:

    systemctl daemon-reload

  5. Start the service:

    systemctl start Talend-CommandLine.service

Installing the service on RedHat/CentOS 6 Systems

  1. Create/Copy the following script to the /etc/init.d/commandline file:

    #!/bin/sh
    ### BEGIN INIT INFO
    # Default-Start:     2 3 4 5
    # Default-Stop:      S 0 1 6
    # Short-Description: Example initscript
    # Description:       This file should be used to construct scripts to be placed in /etc/init.d.
    ### END INIT INFO
    
    # Author: jsd03
    
    # Do NOT "set -e"
    
    # PATH should only include /usr/* if it runs after the mountnfs.sh script
    PATH=/usr/sbin:/usr/bin:/sbin:/bin
    COMMANDLINE=/oa/talend/commandline303
    CMD_WORKSPACE=$COMMANDLINE"/commandline-workspace"
    STARTUP=commandline.sh
    USER=cxp
    NAME=commandline
    PORT=10004
    
    
    # Read configuration variable file if present
    [ -r /etc/default/$NAME ] && . /etc/default/$NAME
    
    # Load the VERBOSE setting and other rcS variables
    [ -f /etc/default/rcS ] && . /etc/default/rcS
    
    # Define LSB log_* functions.
    # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
    . /lib/lsb/init-functions
    
    #
    # Function that starts the daemon/service
    #
    do_start()
    {
    echo -n $"Starting commandline service: "
     su - $USER -c "rm -Rf $CMD_WORKSPACE"
     su - $USER -c "cd $COMMANDLINE && screen -dmS cmdLine ./$STARTUP"
    #screen -dmS cmdLine $DAEMON_START
     RETVAL=$?
     echo
    
    }

    #
    # Function that stops the daemon/service
    #
    do_stop()
    {
     echo -n $"Stopping commandline service: "
     su - $USER -c "( echo 'stopServer' ; sleep 2 ) | telnet localhost $PORT"
     RETVAL=$?
     echo
    
    }
    
    case "$1" in
    start)
    do_start
     ;;
    stop)
     do_stop
     ;;
    *)
     echo $"Usage: $0 {start|stop}"
     exit 1
    esac
    
    exit 0

  2. Edit the USER and COMMANDLINE variable values in the script (with the dedicated user to run Talend, and the CommandLine path respectively).

  3. To make sure that the script is executable, type:

    # chmod 0755 /etc/init.d/commandline

  4. Type in:

    chkconfig --list

    chkconfig --add commandline

    Now, you can test this self-defined service.