Skip to content

Server Daemon Notes

andrewnicols edited this page Nov 5, 2014 · 2 revisions

Choice of Server environment

  • Flask
  • Twisted
  • BottlePY

Protocol

Most likely TCP with a set port Port: 6350 MDK+

Potentially a UNIX socket too

Web Service format

JSON - easy JS integration

Daemonize the current MDK client

Make current MDK a server-based daemon and then write a light-weight client which mirrors existing functionality. Each command sparks off a new job. Each job writes it's logs and can be inspected.

Examples

Start a new job

mdk behat -r -t mod_forum
= Spawning job 143.
Initialising Behat, please be patient!
Updating to version ffffab37a294f3383c812d0329623f0a4ba45387.
...

Hitting Ctrl+C does not cancel the job, but instead backgrounds it

= Job 143 has been backgrounded.
= To inspect, run mdk job view 143
= To see the state of jobs, you can use mdk job list

View job states:

mdk job list
= Job  | State     | Started By   | Instance | Command   | Args  
=------|-----------|--------------|----------|-----------|-----------------
= 140  | Failed    | CLI (nicols) | im       | behat     | -r -t mod_forum
= 141  | Complete  | CLI (nicols) | im       | behat     | -r -t mod_forum
= 142  | Cancelled | Web          | im       | yuidoc    |
= 143  | Running   | CLI (nicols) | im       | behat     | -r -t mod_forum

Or just running jobs:

mdk job list --running
=------|-----------|--------------|----------|-----------|-----------------
= Job  | State     | Started By   | Instance | Command   | Args  
= 143  | Running   | CLI (nicols) | im       | behat     | -r -t mod_forum

Or just failed:

mdk job list --failed
=------|-----------|--------------|----------|-----------|-----------------
= Job  | State     | Started By   | Instance | Command   | Args  
= 140  | Failed    | CLI (nicols) | im       | behat     | -r -t mod_forum

Cancel a job:

mdk job cancel 142

Benefits

  • A single MDK daemon can handle both CLI and Web - simplified API
  • MDK can be run as the standard web-server user - simplified permissions

References

Similar job-style python projects:

  • Ganeti
  • Deluge