5.4 KiB
5.4 KiB
REST API
Process API
Start a new process
Request
POST /process
channel(optional) - the id of the channel which should be subscribed to the process eventstypes(optional) - comma separated types works only in couple with specifiedchannel, defines the events which will be sent by the process to thechannel. Several values may be specified, e.g.channel=channel-1&types=stderr,stdout. By default channel will be subscribed to all the existing types(listed below). Possible type values:stderr- output from the process stderrstdout- output from the process stdoutprocess_status- the process status events(started, died)
{
"name" : "build",
"commandLine" : "mvn clean install",
"type" : "maven"
}
Response
{
"pid": 1,
"name": "build",
"commandLine": "mvn clean install",
"type" : "maven",
"alive": true,
"nativePid": 9186
}
200if successfully started400if incoming data is not valid e.g. name is empty404if specifiedchanneldoesn't exist500if any other error occurs
Get a process
Request
GET /process/{pid}
pid- the id of the process to get
Response
{
"pid": 1,
"name": "build",
"commandLine": "mvn clean install",
"type" : "maven",
"alive": false,
"nativePid": 9186,
}
200if response contains requested process400ifpidis not valid, unsigned int required404if there is no such process500if any other error occurs
Kill a process
Request
DELETE /process/{pid}
pid- the id of the process to kill
Response
{
"pid": 1,
"name": "build",
"commandLine": "mvn clean install",
"type" : "maven",
"alive": true,
"nativePid": 9186,
}
200if successfully killed400ifpidis not valid, unsigned int required404if there is no such process500if any other error occurs
Get process logs
Request
GET /process/{pid}/logs
pid- the id of the process to get logsfrom(optional) - time to get logs from e.g. 2016-07-12T01:48:04.097980475+03:00 the format is RFC3339Nano don't forget to encode this query parametertill(optional) - time to get logs till e.g. 2016-07-12T01:49:04.097980475+03:00 the format is RFC3339Nano don't forget to encode this query parameterformat(optional) - the format of the response, default isjson, possible values are:text,jsonlimit(optional) - the limit of logs in result, the default value is 50, logs are limited from the latest to the earliestskip(optional) - the logs to skip, default value is0
Response
The result logs of the process with the command line printf "Hello\nWorld\n"
Text:
[STDOUT] 2016-07-04 08:37:56.315082296 +0300 EEST Hello
[STDOUT] 2016-07-04 08:37:56.315128242 +0300 EEST World
Json:
[
{
"Kind" : "STDOUT",
"Time" : "2016-07-16T19:51:32.313368463+03:00",
"Text" : "Hello"
},
{
"Kind" : "STDOUT",
"Time" : "2016-07-16T19:51:32.313603625+03:00",
"Text" : "World"
}
]
200if logs are successfully fetched400iffromortillformat is invalid404if there is no such process500if any other error occurs
Get processes
Request
GET /process
all(optional) - iftruethen all the processes including dead ones will be returned(respecting paging ofc), otherwise only alive processes will be returnedg
Response
The result of the request GET /process?all=true
[
{
"pid": 1,
"name": "build",
"commandLine": "mvn clean install",
"type" : "maven",
"alive": true,
"nativePid": 9186,
},
{
"pid": 2,
"name": "build",
"commandLine": "printf \"Hello World\"",
"alive": false,
"nativePid": 9588
}
]
200if processes are successfully retrieved500if any error occurs
Subscribe to the process events
Request
POST /process/{pid}/events/{channel}
pid- the id of the process to subscribe tochannel- the id of the webscoket channel which is subscribertypes(optional) - the types of the events separated by comma e.g.?types=stderr,stdoutafter(optional) - process logs which appeared after given time will be republished to the channel. This method may be useful in the reconnect process
Response
200if successfully subscribed400if any of the parameters is not valid404if there is no such process or channel500if any other error occurs
Unsubscribe from the process events
Request
DELETE /process/{pid}/events/{channel}
pid- the id of the process to unsubscribe fromchannel- the id of the webscoket channel which currenly subscribed to the process events
Response
200if successfully unsubsribed400if any of the parameters is not valid404if there is no such process or channel500if any other error occurs
Update the process events subscriber
Request
PUT /process/{pid}/events/{channel}
pid- the id of the processchannel- the id of the websocket channel which is subscribertypes- the types of the events separated with comma e.g.?types=stderr,stdout
Response
200if successfully updated400if any of the parameters is not valid404if there is no such process or channel500if any other error occurs