Plesk SDK API gives you the ability to execute long tasks and display
their progress in the Plesk UI. To launch a long task and track it
afterwards, create a long task class that extends
pm_LongTask_Task
and define its
run()
method. It is also possible to customize the behavior of a long task by
overriding the
onStart(),
onError(),
and
onDone()
methods that do nothing by default.
While implementing the
run()
method, you may need to get some information about the task via getters
(getInstanceId(),
getParam(),
getParams(),
getStatus(),
and
getProgress()),
and update information about the task via setters
(setParam(),
setParams(),
and
updateProgress()).
Any scalar data types & arrays are accepted as task parameters. Objects
cannot be task parameters.
Long task execution is presented in the Plesk UI by default. The
statusMessage()
method is responsible for displaying the message that appears in the
task progress bar. Long task progress can be either trackable or not (by
default, it is not trackable). If you would like to make task progress
trackable, the value of the $trackProgress property must be set to
“true”, and task progress can be updated via the
updateProgress()
method…