Checking Results of Schedule-based Hooks
With the command line tool, you can browse the history of execution results of server code called by schedule-based hooks. The tool allows you to get a list of the execution results and also the detailed information of each result.
Listing execution results of server code
You can get a list of server code execution results that are launched by schedule-based hooks with the following command:
node bin/kii-servercode.js list-scheduled-execution \
--site jp \
--app-id <your_app_id> \
--app-key <your_app_key> \
--client-id <your_client_id> \
--client-secret <your_client_secret> \
--from <start_date> \
--to <end_date> \
--utc-time
Here are the command options:
- --site: The server location (
jp
). - --app-id: AppID.
- --app-key: An arbitrary value.
- --client-id: ClientID.
- --client-secret: ClientSecret.
- --from: The starting date and time from which the list will be shown (e.g. 2014-02-08).
- --to: The ending date and time until which the list will be shown (e.g. 2014-04-30). When omitted, the current time will be applied.
- --utc-time: Use UTC for date and time.
- --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
The date and time is to be specified either with ISO 8601 format or in YYY-MM-DD HH:mm:ss format. By default, the command line tool accepts the local time. If you want to use UTC, set --utc-time option.
Make sure to set the values you've got on the developer portal for --site, --app-id, --app-key, --client-id and -- client-secret. You can optionally specify the app admin token with --token instead of specifying the ClientID and ClientSecret (See Admin Features to learn how to get the app admin token).
Kii Cloud will return the list as follows:
ID STARTED (LOCAL) FINISHED (LOCAL) STATUS JOB NAME
--------------------------------------------------------------------------
wtwer8y 2014-01-24 12:02:45 RUNNING moveObjectsToUserBucket
w78eryy 2014-01-23 12:02:45 2014-01-23 12:10:45 SUCCESS moveObjectsToUserBucket
gdgyg5g 2014-01-22 12:02:45 2014-01-22 12:10:45 SUCCESS cleanUpMessagesBucket
ijj4uyd 2014-01-21 12:02:45 2014-01-22 12:10:45 FAILED deleteInactiveUsers
- ID: The execution ID assigned to each server code execution. We will use this ID when we get the detailed results.
- STARTED: The date and time when the execution started.
- FINISHED: The date and time when the execution finished.
- STATUS: The execution status (SUCCESS/FAILED/RUNNING).
- JOB NAME: The job name assigned when you define the hook for the scheduled execution (See Schedule-based Hook for more details).
The date and time will be shown in the local time by default. If you specified --utc-time option, it will be shown in UTC.
Getting a detailed execution result
You can check the details of an execution result of server code with the following command:
node bin/kii-servercode.js get-scheduled-execution \
--site jp \
--app-id <your_app_id> \
--app-key <your_app_key> \
--client-id <your_client_id> \
--client-secret <your_client_secret> \
--id <id>
Here are the options you need to set:
- --site: The server location (
jp
). - --app-id: AppID.
- --app-key: An arbitrary value.
- --client-id: ClientID.
- --client-secret: ClientSecret.
- --id: The execution ID you want to get the detail.
- --http-proxy: (optional) Specify http proxy, in case client is running behind a firewall or cannot access directly to Kii 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. You can optionally specify the app admin token with --token instead of specifying the ClientID and ClientSecret (See Admin Features to learn how to get the app admin token).
Kii Cloud will respond as follows:
{
"scheduledExecutionID": "fdueni3d",
"started": 123344546,
"finished": 123233345,
"status": "FAILED",
"name": "deleteInactiveUsers",
"result": "Error found while deleting user: f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
}
The following information is recorded in the "result":
- If the auto execution succeeded, the value in the return statement will be recorded for synchronous codes. For asynchronous codes, the parameter passed to the callback function
done
will be recorded. - If the auto execution failed, the detail of the failure reason, such as the exception message, will be recorded.