Deploying 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 jp \
  --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 (jp).
  • --app-id: The AppID.
  • --app-key: An arbitrary value.
  • --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). v20240715 is the recommended value. 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 Remarks
    6 Engine equivalent to Node.js 6.X. The default engine until Jan. 31, 2025 and will no longer be available from Feb. 1, 2025.
    16 Engine equivalent to Node.js 16.X.
    v20240715 Stable version of 16. The recommended value. This will become the default engine soon from Feb. 1, 2025.
  • --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 versions).

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 Management Features for Server Code. For more information about the command, see Listing Available Versions and Switching the Active Server Code.

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

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