My expectation of the flow would be:
- Attempt to install the script using the AddService event
- On failure, store the data necessary for performing that action on a new plugin table, including the service ID, and write a log regarding the failure
- Setup a cron job to run every 5 minutes that looks for records in that plugin table and:
- Check whether the action has been performed already or not (e.g. by querying the API to see if the script is installed). If it is, delete the record from the plugin table
- If the script is not installed, attempt to install it using the data available from the plugin table
- When the script is installed, delete the record from the plugin table
- If the script continues to fail, try at most 3 times (also stored and incrementing on the plugin table), then write a log regarding the last failed attempt
This cron can be used for any scripts that cannot be provisioned immediately. So for example, with CentOSWebPanel, it may be better to not attempt the script installation immediately from the AddService event since it is known to always fail. Instead, save the information for the cron to attempt it later.
My expectation of the flow would be:
This cron can be used for any scripts that cannot be provisioned immediately. So for example, with CentOSWebPanel, it may be better to not attempt the script installation immediately from the AddService event since it is known to always fail. Instead, save the information for the cron to attempt it later.