Skip to content

pman: long process

Rudolph Pienaar edited this page Mar 9, 2017 · 12 revisions

pman: long process

Abstract

This page describes using pman to start a process that will run for a reasonable amount of time, and show how to query for this process, and also how pman reports failure conditions.

Preconditions

  • This page assumes that pman is listening on: 172.17.0.2:5010.
  • Make sure that pman has been started (see here for more info):
pman --raw 1 --http  --port 5010 --listeners 12
  • This page assumes that a previous run has been managed with parameters
{  "action": "run",
        "meta": {
                "cmd":      "sleep 30",
                "auid":     "rudolphpienaar",
                "jid":      "sleep-1234",
                "threaded": true
        }
}

This spawns a simple sleep process that essentially just does nothing for 30 seconds. In this example we will explore what is returned while the process is still running, what is returned when it ends, and also what happens if a process dies unexpectedly.

start sleeping...

Type a new purl command starting with (just copy/paste the following into a terminal):

purl --content-type application/vnd.collection+json --content-type application/vnd.collection+json  --verb POST  --raw  --http 172.17.0.2:5010/api/v1/cmd  --jsonwrapper 'payload'  --msg \

and finish with the relevant msg payload:

'{  "action": "run",
        "meta": {
                "cmd":      "sleep 30",
                "auid":     "rudolphpienaar",
                "jid":      "sleep-1234",
                "threaded": true
        }
}' --quiet --jsonpprintindent 4 

to start the sleep process.

check on process while sleeping

Now, copy paste above purl prefix and use as msg payload:

start status

'{  "action": "status",
        "meta": {
                "key":          "jid",
                "value":        "sleep-1234"
        }
}' --quiet --jsonpprintindent 4  

which should return

{
    "payloadsize": 80,
    "action": "status",
    "meta": {
        "value": "sleep-1234",
        "key": "jid"
    },
    "d_ret": {
        "0.end": {
            "jobRoot": "20170308164211.942222_5f540393-9ed4-489e-8a65-1ae636d16424",
            "returncode": []
        },
        "l_status": [
            "started"
        ],
        "0.start": {
            "jobRoot": "20170308164211.942222_5f540393-9ed4-489e-8a65-1ae636d16424",
            "startTrigger": [
                true
            ]
        }
    },
    "status": true,
    "RESTverb": "POST",
    "RESTheader": "POST /api/v1/cmd HTTP/1.1\r",
    "receivedByServer": [
        "POST /api/v1/cmd HTTP/1.1\r",
        "Host: 172.17.0.2:5010\r",
        "User-Agent: PycURL/7.43.0 libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3\r",
        "Accept: */*\r",
        "Content-type: application/vnd.collection+json\r",
        "Content-Length: 80\r",
        "\r",
        "{\"payload\": {\"action\": \"status\", \"meta\": {\"key\": \"jid\", \"value\": \"sleep-1234\"}}}"
    ],
    "path": "/api/v1/cmd"
}

Note that the l_status is returned as started. Note also that the 0.end->returncode list is empty, denoting that the process has not ended.

end status

Once the job has finished, we can ask for its status. As before, copy paste the purl prefix and use the same msg payload:

'{  "action": "status",
        "meta": {
                "key":          "jid",
                "value":        "sleep-1234"
        }
}' --quiet --jsonpprintindent 4  

This time the return JSON contains:

    "d_ret": {
      ...
      "l_status": [
            "finishedSuccessfully"
        ]
      ...
    }
'{  "action": "done",
        "meta": {
                "key":          "jid",
                "value":        "cal-job-1234"
        }
}' --quiet --jsonpprintindent 4  

info

'{  "action": "info",
        "meta": {
                "key":          "jid",
                "value":        "cal-job-1234",
                "path":         "/"
        }
}' --quiet --jsonpprintindent 4  

quit

'{  "action": "quit",
    "meta": {
                "when":         "now",
                "saveDB":       true
            }
}' --quiet --jsonpprintindent 4

--30--

Clone this wiki locally