Sectionctl Advanced Options

package.json configuration

You can add configuration for sectionctl to your package.json. sectionctl will read from the package.json and use these flags set here if not specified by the command.

It follows the template:

{
    "name": "first-section-app",
    "version": "0.1.0",
    "section": {
        "accountId": "1234", // same as  -a or --account-id
        "appId": "1234", // same as -i or --app-id
        "environment": "Production", // same as -e or --environment
        "module-name":  "nodejs", // same as --app-path
        "start-script": "production" // runs this script when starting your app
    },
    "scripts": {
        "start": "node devServer.js",
        "production": "node productionServer.js",
        "deploy": "sectionctl deploy"
    }
}

Example: running sectionctl deploy without any flags from the root of your app will read the account and app IDs from your package.json.

Monitor the state of an application

You can use the following command to see the state of an application

sectionctl ps --watch

This will return the status of running app instances in the following format:

|     APP INSTANCE NAME     | APP STATUS | APP PAYLOAD ID |
|---------------------------|------------|----------------|
| nodejs-example-app-name-1 | Running    | unique-id-1    |
| nodejs-example-app-name-2 | Running    | unique-id-2    |

Once an app instance finishes deploying, its status will change from Deploying to Running, and replace the app instances running the older version.

View app Logs

You can use the following command to see the logs of an application

sectionctl logs -a 1234 -i 1234

Use the --follow tag to get live mirrored logging. You will need to use an instance-name, which you can get from sectionctl ps. The resulting command looks like:

sectionctl logs -a 1234 -i 1234 --instance-name nodejs-12345abc-1abc-1a2 --follow

(make sure to substitute your account ID, app ID, and instance-name when you run this command)

Continuous integration mode (CI)

Suppress non-error output by appending the --quiet flag to the end of each command, or by setting the system environment variable “SECTION_CI” to true.

Enable debug output

Log debug output to the console with the --debug flag, or by setting the system enviroment variable “DEBUG” to true.

Add NGINX Server Configuration (Optional)

In your app’s root directory, you can add a configuration file named server.conf to control how NGINX will interact with your server.

The default server.conf is provided below:

location / {
    proxy_set_header X-Forwarded-For $http_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header Host $host;
    include /etc/nginx/section.module/node.conf;
}
location ~ "/next-proxy-hop/" {
    proxy_set_header X-Forwarded-For $http_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header Host $host;
    proxy_pass http://next-hop;
}

Node.js Edge App Hosting is a new Section product, so it may have some rough edges. If you see something that needs improvement, we’d love to hear your feedback.