Skip to main content Skip to complementary content

Building a start() script

In this section, you will need to write the scripts below to build a Linux service script TALEND-INIT-including start() and stop() scripts.

Main steps in start() section:

Procedure

  1. Write the addServer script below to declare Talend Runtime server to Talend Administration Center:
    
    echo $"Starting Talend Runtime Registration ...."
    # Read current Runtime host by using AWS instance Metadata API call, returned host address will be returned in system variable “host_address”.
    host_address=$(curl http://169.254.169.254/latest/meta-data/public-hostname)
                        
    # Build MetaServlet JSON script – addServer.
    metaservlet='{"actionName": "addServer","adminConsolePort": 8040,"authPass": "admin","authUser": "admin@company.com","commandPort": 8000,"description": "RemoteRT","filePort": 8001,"host": "'$host_address'","instance": "trun","label": "RemoteRT_'$host_address'","mgmtRegPort": 1099,"mgmtServerPort": 44444,"monitoringPort": 8888,"runtimePassword": "tadmin","runtimeUsername": "tadmin","shutdownBehavior": "Stop","timeoutUnknownState": "120","useSSL": false}'
                        
    # Run base64url.sh to encode “addServer” script within Base64.
    metaservlet=`echo "$metaservlet" | /app/base64url.sh`
                        
    # Execute REST Call to TAC MetaServlet with encoded string and extract server ID from JSON response.  
    serverId=$(curl -s 'http://{TACHost}:8080/org.talend.administrator/metaServlet?' -X POST -H 'Content-Type: application/json' -d "$metaservlet" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]';)
    
    # Export the server ID as Linux environment variables so it can be used by later process.
    echo 'serverId='$serverId > /etc/environment
                    
  2. Write the saveEsbTask script below to create a new ESB task (service) in Talend Administration Center/ESB Conductor.
    
    echo $"Creating new ESB Task ...."
    # Build MetaServlet JSON script – saveEsbTask.
    metaservlet='{"actionName": "saveEsbTask","authPass": "admin","authUser": "admin@company.com","description": "esbTask from '$host_address'","featureName": "testREST-feature","featureType": "SERVICE","featureUrl": "mvn:org.example/testREST-feature/0.1.0-SNAPSHOT/xml","featureVersion": "0.1.0-SNAPSHOT","repository": "snapshots","runtimeContext": "Default","runtimePropertyId": "testREST","runtimeServerName": "RemoteRT_'$host_address'","tag": "tag1","taskName": "ESBTaskMetaservlet_'$host_address'"}'
                        
    # Run base64url.sh to encode “saveEsbTask” script within Base64.
    metaservlet=`echo "$metaservlet" | /app/base64url.sh`
                        
    # Execute REST Call to TAC MetaServlet with encoded string and extract esbtask ID from JSON response.
    esbtaskId=$(curl -s 'http://{TACHost}:8080/org.talend.administrator/metaServlet?' -X POST -H 'Content-Type: application/json' -d "$metaservlet" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["taskId"]';)
                        
    # Export the ESB Task ID as Linux environment variables so it can be used by later process.
    echo 'esbtaskId='$esbtaskId >> /etc/environment
                    
  3. Write the requestDeployEsbTask script below to request Talend Runtime to deploy the ESB task previously created in "saveEsbTask".
    echo $"Deploying new ESB Task ...."
    # Build MetaServlet JSON script – requestDeployEsbTask.
    metaservlet='{"actionName": "requestDeployEsbTask","authPass": "admin","authUser": "admin@company.com","taskId": '$esbtaskId'}'
                        
    # Run base64url.sh to encode “requestDeployEsbTask” script within Base64.
    metaservlet=`echo "$metaservlet" | /app/base64url.sh`
                        
    # Execute REST Call to TAC MetaServlet with encoded string.
    curl -s 'http://{TACHost}:8080/org.talend.administrator/metaServlet?' -X POST -H 'Content-Type: application/json' -d "$metaservlet"
                    

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!