More content in docs section

This commit is contained in:
Pēteris Caune 2015-08-01 23:02:51 +03:00
parent 3bafac24ba
commit 0501a131ae
6 changed files with 176 additions and 90 deletions

View File

@ -83,9 +83,13 @@ def check_token(request, username, token):
user = authenticate(username=username, password=token) user = authenticate(username=username, password=token)
if user is not None: if user is not None:
if user.is_active: if user.is_active:
# This should get rid of "welcome_code" in session
request.session.flush()
user.set_unusable_password() user.set_unusable_password()
user.save() user.save()
auth_login(request, user) auth_login(request, user)
return redirect("hc-index") return redirect("hc-index")
return render(request, "bad_link.html") return render(request, "bad_link.html")

View File

@ -53,9 +53,17 @@ def pricing(request):
def docs(request): def docs(request):
if "welcome_code" in request.session:
code = request.session["welcome_code"]
check = Check.objects.get(code=code)
else:
check = Check(code="uuid-goes-here")
ctx = { ctx = {
"page": "docs", "page": "docs",
"ping_endpoint": settings.PING_ENDPOINT "ping_endpoint": settings.PING_ENDPOINT,
"check": check,
"ping_url": check.url()
} }
return render(request, "front/docs.html", ctx) return render(request, "front/docs.html", ctx)

View File

@ -1258,7 +1258,7 @@ h1,
} }
h2, h2,
.h2 { .h2 {
font-size: 30px; font-size: 24px;
} }
h3, h3,
.h3 { .h3 {

View File

@ -53,7 +53,7 @@
@font-size-small: ceil((@font-size-base * 0.85)); // ~12px @font-size-small: ceil((@font-size-base * 0.85)); // ~12px
@font-size-h1: floor((@font-size-base * 2.6)); // ~36px @font-size-h1: floor((@font-size-base * 2.6)); // ~36px
@font-size-h2: floor((@font-size-base * 2.15)); // ~30px @font-size-h2: 24px;
@font-size-h3: ceil((@font-size-base * 1.7)); // ~24px @font-size-h3: ceil((@font-size-base * 1.7)); // ~24px
@font-size-h4: ceil((@font-size-base * 1.25)); // ~18px @font-size-h4: ceil((@font-size-base * 1.25)); // ~18px
@font-size-h5: @font-size-base; @font-size-h5: @font-size-base;

View File

@ -4,9 +4,9 @@
{% block title %}Documentation - healthchecks.io{% endblock %} {% block title %}Documentation - healthchecks.io{% endblock %}
{% block content %} {% block content %}
<div class="row"> <div class="row"><div class="col-sm-12">
<div class="col-sm-12">
<h3>Summary</h3> <h2>Summary</h2>
<p> <p>
Each check you create in <a href="{% url 'hc-index' %}">My Checks</a> Each check you create in <a href="{% url 'hc-index' %}">My Checks</a>
page has an unique "ping" URL. Whenever you access this URL, page has an unique "ping" URL. Whenever you access this URL,
@ -16,10 +16,10 @@
check is considered "late", and Health Checks sends an email alert. check is considered "late", and Health Checks sends an email alert.
It is all very simple, really.</p> It is all very simple, really.</p>
<h3>Executing a Ping</h3> <h2>Executing a Ping</h2>
<p> <p>
At the end of your batch job, add a bit of code to request At the end of your batch job, add a bit of code to request
one of your ping URLs. your ping URL.
</p> </p>
<ul> <ul>
<li>HTTP and HTTPS protocols both are fine</li> <li>HTTP and HTTPS protocols both are fine</li>
@ -32,13 +32,88 @@
short and simple string "OK".</p> short and simple string "OK".</p>
<p> <p>
In bash scripts, you can use <code>wget</code> or <code>curl</code> to run the requests: Here are examples of executing pings from different environments.
</p> </p>
<pre>
curl {{ ping_endpoint }}{uuid-goes-here}
</pre>
<h3>When Alerts Are Sent</h3> <h3>Crontab</h3>
<p>
When using cron, probably the easiest is to append a <code>curl</code>
or <code>wget</code> call after your command. The scheduled time comes,
and your command runs. After it completes, the healthchecks.io check
gets pinged.
</p>
{% include "front/snippets/crontab.html" %}
<p>With this simple modification, you monitor several failure
scenarios:</p>
<ul>
<li>The whole machine has stopped working (power outage, janitor stumbles on wires, VPS provider problems, etc.) </li>
<li>cron daemon is not running, or has invalid configuration</li>
<li>cron does start your task, but the task exits with non-zero exit code</li>
</ul>
<p>Either way, when your task doesn't finish successfully, you will soon
know about it.</p>
<h3>Bash or a shell script</h3>
<p>Both <code>curl</code> and <code>wget</code> examples accomplish the same
thing: they fire off a HTTP GET method.</p>
<p>
If using <code>curl</code>, make sure it is installed on your target system.
Ubuntu, for example, does not have curl installed out of the box.
</p>
{% include "front/snippets/bash.html" %}
<h3>Python</h3>
{% include "front/snippets/python.html" %}
<h3>Node</h3>
{% include "front/snippets/node.html" %}
<h3>PHP</h3>
{% include "front/snippets/php.html" %}
<h3>Browser</h3>
<p>
healthchecks.io includes <code>Access-Control-Allow-Origin:*</code>
CORS header in its ping responses, so cross-domain AJAX requests
should work.
</p>
{% include "front/snippets/browser.html" %}
<h3>Email</h3>
<p>
As an alternative to HTTP/HTTPS requests,
you can "ping" this check by sending an
email message to <a href="mailto:{{ check.email }}">{{ check.email }}</a>
</p>
<p>
This is useful for end-to-end testing weekly email delivery.
</p>
<p>
An example scenario: you have a cron job which runs weekly and
sends weekly email reports to a list of e-mail addresses. You have already
set up a check to get alerted when your cron job fails to run.
But what you ultimately want to check is your emails <em>get sent and
get delivered</em>.
</p>
<p>
The solution: set up another check, and add its
@hchk.io address to your list of recipient email addresses. Set its
Period to 1 week. As long as your weekly email script runs correctly,
the check will be regularly pinged and will stay up.
</p>
<h2>When Alerts Are Sent</h2>
<p> <p>
Each check has a configurable <strong>Period</strong> parameter, with the default value of one day. Each check has a configurable <strong>Period</strong> parameter, with the default value of one day.
For periodic tasks, this is the expected time gap between two runs. For periodic tasks, this is the expected time gap between two runs.
@ -94,6 +169,5 @@ curl {{ ping_endpoint }}{uuid-goes-here}
</tr> </tr>
</table> </table>
</div> </div></div>
</div>
{% endblock %} {% endblock %}

View File

@ -82,7 +82,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div id="get-started" class="col-sm-6 col-sm-offset-3"> <div id="get-started" class="col-sm-6 col-sm-offset-3">
<h3>E-mail Address to Receive Alerts:</h3> <h2>E-mail Address to Receive Alerts:</h2>
<form action="{% url 'hc-login' %}" method="post"> <form action="{% url 'hc-login' %}" method="post">
{% csrf_token %} {% csrf_token %}