Skip to content

pman command: run

Rudolph Pienaar edited this page Mar 8, 2017 · 22 revisions

pman command: run

Abstract

This page describes the run command to pman. It is used to spawn a process on the underlying shell/OS.

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

msg summary

The msg payload of the REST interaction with pman is:

{  "action": "run",
        "meta": {
                "cmd":      "cal 7 1970",
                "auid":     "rudolphpienaar",
                "jid":      "cal-job-1234",
                "threaded": true
        }
}

run

The real purpose of pman is to manage processes. Let's send it a simple job, the UNIX calendar command to simply print a month in a given year. In this case, the command we wish to run is cal 7 1970. Using purl this can be specified with:

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 \
'{  "action": "run",
        "meta": {
                "cmd":      "cal 7 1970",
                "auid":     "rudolphpienaar",
                "jid":      "cal-job-1234",
                "threaded": true
        }
}' --quiet --jsonpprintindent 4 

return payload

The above call returns the JSON string:

{
    "meta": {
        "jid": "cal-job-1234",
        "threaded": true,
        "cmd": "cal 7 1970",
        "auid": "rudolphpienaar"
    },
    "status": true,
    "path": "/api/v1/cmd",
    "jobRootDir": "20170303164938.122651_6e09943c-6fc0-45c8-b088-2394e5886b69",
    "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: 128\r",
        "\r",
        "{\"payload\": {\"meta\": {\"jid\": \"cal-job-1234\", \"threaded\": true, \"cmd\": \"cal 7 1970\", \"auid\": \"rudolphpienaar\"}, \"action\": \"run\"}}"
    ],
    "action": "run",
    "payloadsize": 128,
    "RESTverb": "POST",
    "RESTheader": "POST /api/v1/cmd HTTP/1.1\r"
}

notes

This job probably had already finished by the time purl had written the above to the terminal.

Clone this wiki locally