Skip to content
This repository has been archived by the owner on Jun 23, 2018. It is now read-only.

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
script-deployer committed Aug 17, 2016
1 parent 885a823 commit 7de92c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions getting_started/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tutorial #1 -- Deploying a Service

This tutorial walks you through deploying a simple service on nstack; as a first example, we're using a demo service which squares a number (don't worry, we'll be adding to it in due course!)

Before we begin, check you've installed nstack as described in :ref:`getting_started_installation`, and attached your toolkit to your nstack machine.
Before we begin, check you've installed nstack as described in :ref:`getting_started_installation`, and attached your toolkit to your nstack-engine.

Creating a Service
------------------
Expand All @@ -25,19 +25,20 @@ This already contains all the files a nstack service needs.

.. code-block:: bash
[demo-python]$ ls
[example-service]$ ls
api.idl app.py nstack.yaml requirements.txt
In the next section, we'll walk through these files:

Service structure
^^^^^^^^^^^^^^^^^^^^
Let's walk through these files.

``app.py``
^^^^^^^^^^

This is a simple python class which comprises your service. As you can see, we're not doing anything particularly exciting here, but this could be as complex as you please.
This is a simple python class which comprises our service. As you can see, we're not doing anything particularly exciting here, but this could be as complex as you please.

.. code-block:: python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import nstack
Expand All @@ -47,7 +48,6 @@ This is a simple python class which comprises your service. As you can see, we'r
return number * number
``nstack.yaml``
^^^^^^^^^
The ``nstack.yaml`` is a *YAML* file containing configuration. Here, it includes any dependencies your service has, the stack (or runtime) for your service, and any operating system dependencies (which are *yum* packages). Because our service is boring at the moment, we don't have any dependencies (yet!)
Expand All @@ -74,6 +74,8 @@ The ``api.idl`` is an interface-definition (IDL) file which describes our servic
One of the features of nstack is that your inputs is type-checked. Here, we are saying we want to expose our function ``sqrt`` which takes an ``int`` and returns an ``int``.

``requirements.txt``
^^^^^^^^


This is the dependencies for Python's package manager. There aren't any yet, so this file is empty.

Expand Down
10 changes: 5 additions & 5 deletions using_service/scheduler.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _scheduler:

nstack Time-Based Scheduling
nstack Scheduler
=====================

Perhaps the simplest way to run an nstack service is to schedule it to run at a certain time. For instance, you can tell your service to run at 5 O'Clock on Mondays, or to run every second. This functionality is aimed at replacing other scheduling systems such as cron.
Expand All @@ -11,21 +11,21 @@ To schedule an existing service to run at a certain time, the format is:

.. code:: bash
$ nstack trigger my-service schedule=0::0::1 entry=myFunction
$ nstack start my-service.myFunction schedule=0::0::1
[Success] Successfully scheduled service, id is [a3bd1a]
This would invoke myFunction with no arguments. If you want to invoke a function with arguments (say a basic adding function), you can:

.. code:: bash
$ nstack trigger my-service schedule=0::0::1 entry=add args=(1, 3)
$ nstack start my-service.add(1,3) schedule=0::0::1
[Success] Successfully scheduled service, id is [a3bd1a]
To list existing scheduled tasks:

.. code:: bash
$ nstack ps | grep schedule
$ nstack list | grep schedule
[a3bd1a] [schedule (:0::0::1)], my-service, Leo Anthias
To get logs from your service, you can use the logs function:
Expand All @@ -44,5 +44,5 @@ And to remove an existing scheduled task:

.. code:: bash
$ nstack kill a3bd1a
$ nstack stop a3bd1a
[Success] Successfully killed service [a3bd1a]

0 comments on commit 7de92c8

Please sign in to comment.