WayScript uses WayScript to simplify and automate many of our DevOps processes. We make heavy use of our own Python API for error tracking and performance monitoring on the live site. We also use our WayScript API for reporting during our AWS deployment process.
In this article, we'll show you some of the ways we use WayScript to make our developers' lives easier and our site more reliable, with the hope that you will be able to use WayScript to improve your own DevOps workflows.
One pain point of our deployment process was that our developers were unaware of when a deployment was taking place or what the status was of an ongoing deployment.
Our team uses Slack, so we decided to solve this problem by using the WayScript API to send deployment updates to a Slack channel.
To send these Slack notifications throughout our deployment process, we created a "Deployment" program.
This program serves three main functions:
Send a link to the deployment progress page when a deployment begins.
Notify the team that a deployment has completed.
Notify the team that an autoscaling event has occurred.
While it may look complicated, the program flow is pretty simple.
- The program starts out with a Webhook Trigger so that it can be triggered by an API call.
- When the message is received, a series of if/else statements determines what type of message to send to Slack, based on the arguments passed to the Webhook Trigger.
- The Slack Module sends the message to our developers.
We use AWS CodeDeploy for our deployments. The CodeDeploy configuration allows you to use "hooks" to run different shell scripts or lambda functions at different stages of the deployment lifecycle. By calling the WayScript API from these hooks, we can easily track the progress of our deployment.
Here is an example of calling the WayScript API from a shell script. This example will run a "Deployment" program, with the argument "Deployment Started!".
WS_API_KEY="your_api_key" # Get this from your Profile page PROGRAM_ID=1234 # ID of your WayScript "Deployment" program python -c "from wayscript import WayScript; WayScript('$WS_API_KEY').run_program($PROGRAM_ID, 'Deployment Started!')"
Of course, for this to work, you'll need to have the WayScript Python Library installed on your application instance.
pip install wayscript
Often, there are times when the development team wants to know if certain events occurred in the code, but doesn't want to dig through various debug logs to find them. These debug events are another great use case for the WayScript API and Slack Module.
Most of the time, we're ok with sending debug event notifications to a Slack channel that the development team occasionally monitors, but some errors are critical enough that we want to alert the team with an email or text message.
To achieve this, we can expand on the debug program above by also passing a "Log Level" argument via our WayScript API call. We can then branch on the value of "Log Level" to:
- Write to Slack "If Log Level is the same as Debug"
- Send an email "If Log Level is the same as Warning"
- Send a text message "If Log Level is the same as Error"
Similar to the way we use WayScript for debugging and error reporting, we can also use WayScript to alert us on performance regressions.
For example, we could send API performance data to WayScript, store it in an Excel file, and run analysis on top of that data, such as determining if a value crosses a certain threshold, or changes by a certain percent.
We also utilize WayScript API calls to notify us of general site activity, such as a user submitting feedback or a bug report.
You can even use WayScript to detect if your site goes down or becomes unreachable. Create a program that uses the Python Module to ping your site. If the ping fails, send an email. Add a Time Trigger to your program to run it every ten minutes (or every minute), and voila, you will now get an email from WayScript if your site goes down!
These are just a few of the ways WayScript uses WayScript to simplify our DevOps workflows and ensure our site is performant and reliable. There are endless ways to use the WayScript API to innovative and enhance your DevOps activities.
We'd love to hear how your team uses the WayScript API in your application. As always, feel free to drop us a line at email@example.com with success stories, feedback, or suggestions for new functionality that would make your DevOps workflows easier.