All Products
Search
Document Center

SchedulerX:Use the agent to connect an application to SchedulerX (Script or HTTP jobs)

Last Updated:Mar 15, 2024

After you use the agent to connect your application to SchedulerX, you can create scheduled jobs, rerun jobs, view execution records, and view operational logs in a visualized manner in the SchedulerX console. This topic describes how to use a.tar package or image of the agent to connect a non-Java application to SchedulerX.

Prerequisites

Scenarios

You can use the SchedulerX agent to connect your application to SchedulerX in the following common scenarios:

  • You want to use a Shell script to periodically clean the logs of all instances or launch a service.

  • You want to use a Python script to periodically clean the historical data in a database.

  • You want to use an HTTP API to periodically scan orders.

Environment requirements

The runtime environment must be Java Runtime Environment (JRE) 1.8 or later.

Manually deploy the agent

  1. Download the package of the agent and decompress the package.

    If your instance is assigned a public IP address, run the following command to download the package:

    Note

    X.X.X specifies the version number of the agent. You can replace X.X.X with the version number of the agent that you want to use, such as 1.9.0.

    wget https://schedulerx2.oss-cn-hangzhou.aliyuncs.com/agent/schedulerxAgent-X.X.X.tar.gz

    Version

    Download URL

    Version description

    Agent 1.10.13

    https://schedulerx2.oss-cn-hangzhou.aliyuncs.com/agent/schedulerxAgent-1.10.13.tar

    New features:

    • Multiple agents can be deployed on a worker at the same time.

    • HTTP agent tasks support responses that are larger than 1,000 bytes in size.

    • Logs are optimized to reduce historical log storage.

    Agent 1.10.5

    https://schedulerx2.oss-cn-hangzhou.aliyuncs.com/agent/schedulerxAgent-1.10.5.tar

    New features:

    • The graceful shutdown feature is supported.

    • Instance groups support the logging feature.

    Agent 1.9.8

    https://schedulerx2.oss-cn-hangzhou.aliyuncs.com/agent/schedulerxAgent-1.9.8.tar

    New features:

    • HTTP jobs are supported by the agent.

    • The log in the last line can be returned after a script job fails to be executed.

    • Kubernetes jobs are supported.

    Agent 1.7.10

    https://schedulerx2.oss-cn-hangzhou.aliyuncs.com/agent/schedulerxAgent-1.7.10.tar.gz

    Fixed issues:

    • Second-delay jobs run at a slow speed.

    • Out of memory (OOM) issues may be caused by Simple Log Service.

    Agent 1.4.2

    https://schedulerx2.oss-cn-hangzhou.aliyuncs.com/agent/schedulerxAgent-1.4.2.tar.gz

    New feature: The logging service is supported.

  2. Go to the schedulerxAgent/conf directory and configure the agent.properties file.

    Configure the following parameters:

    endpoint=addr-hz-internal.edas.aliyun.com
    namespace=fd2965c4-****-****-af52-bb62aa4*****
    groupId=hxm.test
    appKey=1234*****
    • Endpoint: the endpoint. For more information, see Endpoints.

    • namespace: the ID of the SchedulerX namespace or the Enterprise Distributed Application Service (EDAS) microservices namespace. You can obtain the ID on the Namespace page in the SchedulerX console.

    • Application ID and Application Key specify the unique ID and key of the application. You can view the application ID and key of the application on the Application Management page of the console.

  3. Go to the schedulerxAgent/bin directory and run the start-200m.sh command to deploy the agent. You can run start-100m.sh, start-100m.sh, or start-500m.sh based on the job load and worker configurations.

    Note

    In this topic, start-200m.sh is used as an example. You can also run start-100m.sh or start-500m.sh based on your job load and worker configurations.

    During the deployment process, you can perform the following operations based on your business requirements:

    • Stop the agent: Go to the schedulerxAgent/bin directory and run the stop.sh command to stop the agent.

    • View the log: The path of the log is ${user.home}/logs/schedulerx/worker.log.

      You can run the ps aux | grep java command to obtain the value of user.home. If you use the admin account to launch the process, the log resides in the /home/admin/logs/schedulerx/worker.log path. If you use the root account to launch the process, the log resides in the /root/logs/schedulerx/worker.log path.

    If the returned information contains Schedulerx Worker started, the agent is deployed.

Use a Docker image to deploy the agent

  1. Select an image based on your network and CPU architecture.

    Network

    x86_64

    arm64

    Internet

    registry.cn-hangzhou.aliyuncs.com/schedulerx/agent:1.6.0-amd64

    registry.cn-hangzhou.aliyuncs.com/schedulerx/agent:1.6.0-arm64

    Virtual private cloud (VPC) in China (Hangzhou)

    registry-vpc.cn-hangzhou.aliyuncs.com/schedulerx/agent:1.6.0-amd64

    registry-vpc.cn-hangzhou.aliyuncs.com/schedulerx/agent:1.6.0-arm64

    VPC in a region other than China (Hangzhou)

    registry-vpc.{regionId}.aliyuncs.com/schedulerx/agent:1.6.0-amd64

    registry-vpc.{regionId}.aliyuncs.com/schedulerx/agent:1.6.0-arm64

  2. Deploy the agent.

    Parameters:

    docker run  --env SCHEDULERX_ENDPOINT="addr-hz-internal.edas.aliyun.com" \
       --env SCHEDULERX_NAMESPACE="fd2965c4-****-****-af52-bb62aa4*****" \
       --env SCHEDULERX_GROUPID="hxm.test" \
       --env SCHEDULERX_APPKEY="1234*****" \
       -d {image id}
    • SCHEDULERX_ENDPOINT specifies the endpoint.

    • SCHEDULERX_NAMESPACE: the ID of the SchedulerX namespace or the EDAS microservices namespace. You can obtain the ID on the Namespace page in the SchedulerX console.

    • SCHEDULERX_GROUPID: the application ID.

    • SCHEDULERX_APPKEY: the application key.

    You can obtain the ID and the key of the application on the Application Management page in the SchedulerX console .

    After you start to deploy the agent, you can run the docker logs command to view logs.