Thứ Năm, 2 tháng 6, 2016

Deploy Your API to an API Gateway

Deploy Your API to an API Gateway

This walkthrough requires an APIkit project or a proxy to deploy to the API Gateway. Complete one of the following tasks:
You can apply the lessons you learn in this walkthrough to creating RESTful and SOAP APIs.
You can deploy an API directly to the gateway only if your subscription allows the number of connectors that you use in the API. For more information, contact Support. Click Support on the top navigation bar of the Anypoint Platform.
If you are deploying to an API Gateway that you are hosting on-premises, install and configure that gateway before proceeding. If you are deploying to a cloud API Gateway, no advanced configuration is required.
You can deploy an API or proxy application to an API Gateway running on your localhost machine. To make your API accessible to other Anypoint Platform users or to the API Console, which accesses your API through a Web proxy, deploy your API on the internet. For example, deploy your API on Cloudhub.
Some capabilities, such as deploying to Cloudhub and creating a proxy might not be available to you, depending onentitlements you purchased.

Deploying

To perform an on-premises deployment of an APIkit project or proxy application to API Gateway:
  1. Download your API as a .zip file from the API version page in the API platform.
  2. Use the cd command to navigate to the $MULE_HOME directory.
    <MULE_HOME> represents the root directory of the installation, typically /opt/Mule/api-gateway-1.8.0/ on Linux.
  3. Run the startup script:
    • Windows: <MULE_HOME>\bin\gateway
    • Linux: <MULE_HOME>/bin/gateway
  4. Navigate to the directory where the API .zip file is located, remove spaces in the file name if there are any, and copy the file. 
  5. Drop the copy of the file into the <MULE_HOME>/apps folder.
    The API Gateway polls this folder for new applications every five seconds. Watch your command line window to track the progress of the deployment.
    1
    2
    3
    4
    5
    6
    7
    
    +++++++++++++++++++++++++++++++++++++++++++++++++++
    + New app 'ProxyExample'                          +
    +++++++++++++++++++++++++++++++++++++++++++++++++++
    INFO  2015-07-02 14:42:54,007 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.MuleDeploymentService:
    +++++++++++++++++++++++++++++++++++++++++++++++++++
    + Started app 'ProxyExample'                      +
    +++++++++++++++++++++++++++++++++++++++++++++++++++
    The APIkit project or proxy application is deployed to the API Gateway.
    The API Gateway detects an existing app update and redeploys the application.
Your app is now synced with the one in your Anypoint Platform account. If you make a change in the API version page, such as applying a policy, the change takes effect momentarily.
To stop the application, navigate to the app directory and delete the file your_application.txt. Use CTRL-C to stop the Gateway. To update the application at runtime, drop a new .zip version of the app into the<MULE_HOME>/apps directory.

Starting API Gateway as a Background Process

Instead of running API Gateway in the foreground, you can run it in the background as follows:
  1. Use the cd command to navigate to the <MULE_HOME>/bin directory.
  2. Run the startup script according to the options below.
    • Windows: gateway.bat start
    • Linux: ./gateway start
      To stop API Gateway, run the script with the stop parameter.
If you add or edit policies on your proxy, there’s no need to redeploy the app, as the changes apply automatically within a few seconds.

Không có nhận xét nào:

Đăng nhận xét