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> \
  --hook-config <hook_file>

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.
  • --token: (optional) The app admin token. Can be used instead of client-id and client-secret.

  • --hook-config: (optional) The Server Hook config file (read here for more information on how to write the config file). If you are only executing manually, you can omit this file.

  • --no-set-current: (optional) Do not activate the deploying Server Code and keep the current version active (read here for more information on the versioning).

  • --http-proxy: (optional) Specify http proxy, in case client is running behind a firewall or cannot access directly to Kii Cloud API. Eg: https://my.proxy:8080

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

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 Server Code while leaving the current version active by setting the --no-set-current option. You can, for example, deploy the Server Code for an event with the -no-set-current option and later enable it when the event starts. Please read Server Code Management for the overview of the Server Code versioning. For more details on the command, please read List the Available Versions and Switch the Active Server Code.