Challenge: Improve Your iModel.js Agent’s Reliability!
Summary
By completing this you will learn how to:
- Make your iModel.js agent more resilient to errors and scheduled maintenance.
Setup
-
Install the required tools
-
Clone the jumpstart-agent repo
-
Follow the setup instructions in the jumpstart-agent README
Goals
Goal Follow the instructions to update the agent so you never miss an iModelHub event.
Bonus Create a new “start:prod” npm script to automatically restart the agent anytime a fatal error occurs.
Solution
The best way to learn is by doing! But, if you want to skip ahead you can go right to the full solution.
Instructions
-
Update
MyAgent.ts
to reuse an existing iModelHub subscription ID (only creating a new event subscription in iModelHub when necessary).If you need help try these hints.
-
Update
MyAgent.ts
to never delete the iModelHub subscription.If you need help try these hints.
- Test out your new behavior!
- Start your agent via
npm start
, wait for it to begin listening, and then stop it. - While your agent is stopped, synchronize new changes via the iTwin Synchronizer.
- Re-start your agent (
npm start
) after iTwin Synchronizer has finished pushing the changeset(s). - If you completed steps 1 & 2 correctly, your agent will pick right up where it left off and see the event it missed!
- Start your agent via
-
(Bonus) Create a new
start:prod
npm script inpackage.json
to automatically restart the agent anytime a fatal error occurs.If you need help try these hints.
Conclusion
So, were you up to the challenge? Check out how we solved it by viewing our full solution. Let us know if you have a better way.
Feedback is welcome! Let us know via the iModel.js community.