Deploy your Server Code

Check the following execution sample to see how to deploy your Server Code.

node bin/kii-servercode.js deploy-file \
  --file ../demo.js \
  --site us \
  --app-id <your_app_id> \
  --app-key <your_app_key> \
  --client-id <your_client_id> \
  --client-secret <your_client_secret> \
  --environment-version <engine_version> \
  --hook-config <hook_file> \
  --set-current

Here are the options you need to set:

  • --file: The Server Code to be deployed.
  • --site: The server location (can be us, jp, cn3, sg, or eu).
  • --app-id: The AppID.
  • --app-key: The AppKey.
  • --client-id: The ClientID.
  • --client-secret: The ClientSecret.
  • --environment-version: The version of the JavaScript engine on which the Server Code is executed (For more information about the JavaScript engine, see JavaScript Engine). 6 is the recommended value as <engine_version>. If this option is omitted, the default JavaScript engine is used and the console outputs a message saying that this option should be specified.

    Value Version Remarks
    0 Node.js 0.10.X The default JavaScript engine. This value can be specified until October 31, 2017
    6 Node.js 6.X The recommended value. The default JavaScript engine after October 31, 2017
  • --token: (optional) The app admin token. Can be used instead of ClientID and ClientSecret.

  • --hook-config: (optional) The Server Hook configuration file (To learn how to write the configuration file, see Server Hook Configuration File). If you execute the Server Code only manually, you can omit this option.

  • --http-proxy: (optional) The HTTP proxy, in case the client is behind a firewall or cannot directly access the Kii Cloud API (e.g., https://my.proxy:8080).

  • --set-current: (optional) This option activates the Server Code being deployed. If omitted, the Server Code being deployed will not be activated and the currently active version will remain active (For more information about versioning, see Managing Server Code Version).

Make sure to set the values you've got on the developer portal for --site, --app-id, --app-key, --client-id and -- client-secret (For more information, see Parameters for Executing the Commands). You can optionally specify the app admin token with --token instead of specifying the ClientID and ClientSecret (To learn how to get the app admin token, see Admin Features).

When the Server Code is successfully deployed, Kii Cloud will return the version assigned to this code as follows:

6 Feb 18:08:37 - Deploying file...
6 Feb 18:08:39 - File deployed as version gulsdf6ful8jvf8uq6fe7vjy6
6 Feb 18:08:39 - Deploying hook config...
6 Feb 18:08:39 - Hook Config deployed at version gulsdf6ful8jvf8uq6fe7vjy6
6 Feb 18:08:39 - Setting current version to gulsdf6ful8jvf8uq6fe7vjy6...
6 Feb 18:08:40 - Current version set to gulsdf6ful8jvf8uq6fe7vjy6

You can deploy a new version of the Server Code while keeping the current version active by omitting the --set-current option. You can, for example, deploy a version of the Server Code for a planned event without the --set-current option and activate it on the day of the event. For an overview of Server Code versioning, see Server Code Management. For more information about the command, see List the Available Versions and Switch the Active Server Code.

We no longer support the --no-set-cuurent option.

If you get an error when using the --set-current option, please update your command line tool to the latest version.