- added command line option -v to daemon to return current version
- set current daemon version to bondagit-1.0 - added HTTP API to return current daemon version and updated documentation - added diplay of current daemon version in WebUI Config page
This commit is contained in:
parent
0cda7c7ad3
commit
399e22216a
@ -30,6 +30,13 @@ All operations returns HTTP *200* status code in case of success and HTTP *4xx*
|
||||
In case of failure the server returns a **text/plain** content type with the category and a description of the error occurred.
|
||||
**_NOTE:_** At present the embedded HTTP server doesn't implement neither HTTPS nor user authentication.
|
||||
|
||||
### Get Daemon Version ###
|
||||
* **URL** /api/version
|
||||
* **Method** GET
|
||||
* **URL Params** none
|
||||
* **Body Type** application/json
|
||||
* **Body** [Version params](#version)
|
||||
|
||||
### Get Daemon Configuration ###
|
||||
* **URL** /api/config
|
||||
* **Method** GET
|
||||
@ -142,6 +149,18 @@ In case of failure the server returns a **text/plain** content type with the cat
|
||||
|
||||
## HTTP REST API structures ##
|
||||
|
||||
### JSON Version<a name="version"></a> ###
|
||||
|
||||
Example
|
||||
{
|
||||
"version:" "bondagit-1.0"
|
||||
}
|
||||
|
||||
where:
|
||||
|
||||
> **version**
|
||||
> JSON string specifying the daemon version.
|
||||
|
||||
### JSON Config<a name="config"></a> ###
|
||||
|
||||
Example
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "main.hpp"
|
||||
#include "json.hpp"
|
||||
#include "log.hpp"
|
||||
#include "http_server.hpp"
|
||||
@ -98,6 +99,12 @@ bool HttpServer::init() {
|
||||
set_headers(res);
|
||||
});
|
||||
|
||||
/* get version */
|
||||
svr_.Get("/api/version", [&](const Request& req, Response& res) {
|
||||
set_headers(res, "application/json");
|
||||
res.body = "{ \"version\": \"" + get_version() + "\" }";
|
||||
});
|
||||
|
||||
/* get config */
|
||||
svr_.Get("/api/config", [&](const Request& req, Response& res) {
|
||||
set_headers(res, "application/json");
|
||||
|
@ -35,6 +35,7 @@ namespace po = boost::program_options;
|
||||
namespace postyle = boost::program_options::command_line_style;
|
||||
namespace logging = boost::log;
|
||||
|
||||
static std::string version("bondagit-1.0");
|
||||
static std::atomic<bool> terminate = false;
|
||||
|
||||
void termination_handler(int signum) {
|
||||
@ -47,14 +48,19 @@ bool is_terminated() {
|
||||
return terminate.load();
|
||||
}
|
||||
|
||||
const std::string& get_version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int rc = EXIT_SUCCESS;
|
||||
po::options_description desc("Options");
|
||||
desc.add_options()(
|
||||
"config,c", po::value<std::string>()->default_value("/etc/daemon.conf"),
|
||||
"daemon configuration file")("http_port,p", po::value<int>(),
|
||||
"HTTP server port")(
|
||||
"help,h", "Print this help message");
|
||||
desc.add_options()
|
||||
("version,v", "Print daemon version and exit")
|
||||
("config,c", po::value<std::string>()->default_value("/etc/daemon.conf"),
|
||||
"daemon configuration file")
|
||||
("http_port,p", po::value<int>(), "HTTP server port")
|
||||
("help,h", "Print this help message");
|
||||
int unix_style = postyle::unix_style | postyle::short_allow_next;
|
||||
|
||||
po::variables_map vm;
|
||||
@ -67,6 +73,10 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("version")) {
|
||||
std::cout << version << '\n';
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (vm.count("help")) {
|
||||
std::cout << "USAGE: " << argv[0] << '\n' << desc << '\n';
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -21,5 +21,6 @@
|
||||
#define _MAIN_HPP_
|
||||
|
||||
bool is_terminated();
|
||||
const std::string& get_version();
|
||||
|
||||
#endif
|
||||
|
@ -30,6 +30,7 @@ class Config extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
version: '',
|
||||
httpPort: '',
|
||||
rtspPort: '',
|
||||
rtspPortErr: false,
|
||||
@ -57,7 +58,8 @@ class Config extends Component {
|
||||
macAddr: '',
|
||||
ipAddr: '',
|
||||
errors: 0,
|
||||
isConfigLoading: false
|
||||
isConfigLoading: false,
|
||||
isVersionLoading: false
|
||||
};
|
||||
this.onSubmit = this.onSubmit.bind(this);
|
||||
this.inputIsValid = this.inputIsValid.bind(this);
|
||||
@ -65,6 +67,16 @@ class Config extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({isConfigLoading: true});
|
||||
this.setState({isVersionLoading: true});
|
||||
RestAPI.getVersion()
|
||||
.then(response => response.json())
|
||||
.then(
|
||||
data => this.setState(
|
||||
{
|
||||
version: data.version,
|
||||
isVersionLoading: false
|
||||
}))
|
||||
.catch(err => this.setState({isVersionLoading: false}));
|
||||
RestAPI.getConfig()
|
||||
.then(response => response.json())
|
||||
.then(
|
||||
@ -105,6 +117,7 @@ class Config extends Component {
|
||||
!this.state.rtspPortErr &&
|
||||
!this.state.sapIntervalErr &&
|
||||
!this.state.syslogServerErr &&
|
||||
!this.state.isVersionLoading &&
|
||||
!this.state.isConfigLoading;
|
||||
}
|
||||
|
||||
@ -130,6 +143,14 @@ class Config extends Component {
|
||||
render() {
|
||||
return (
|
||||
<div className='config'>
|
||||
{this.state.isVersionLoading ? <Loader/> : <h3>Version</h3>}
|
||||
<table><tbody>
|
||||
<tr>
|
||||
<th align="left"> <label>Daemon</label> </th>
|
||||
<th align="left"> <input value={this.state.version} disabled/> </th>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<br/>
|
||||
{this.state.isConfigLoading ? <Loader/> : <h3>Audio Config</h3>}
|
||||
<table><tbody>
|
||||
<tr>
|
||||
@ -140,10 +161,6 @@ class Config extends Component {
|
||||
<th align="left"> <label>TIC frame size @1FS (samples) </label> </th>
|
||||
<th align="left">
|
||||
<select value={this.state.ticFrameSizeAt1fs} onChange={e => this.setState({ticFrameSizeAt1fs: e.target.value})}>
|
||||
<option value="6">6 - 125μs</option>
|
||||
<option value="12">12 - 250μs</option>
|
||||
<option value="16">16 - 333μs</option>
|
||||
<option value="24">24 - 500μs</option>
|
||||
<option value="48">48 - 1ms</option>
|
||||
<option value="96">96 - 2ms</option>
|
||||
<option value="192">192 - 4ms</option>
|
||||
|
@ -21,6 +21,7 @@
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
const API = '/api';
|
||||
const version = '/version';
|
||||
const config = '/config';
|
||||
const streams = '/streams';
|
||||
const sources = '/sources';
|
||||
@ -69,6 +70,13 @@ export default class RestAPI {
|
||||
);
|
||||
}
|
||||
|
||||
static getVersion() {
|
||||
return this.doFetch(version).catch(err => {
|
||||
toast.error('Config get failed: ' + err.message);
|
||||
return Promise.reject(Error(err.message));
|
||||
});
|
||||
}
|
||||
|
||||
static getConfig() {
|
||||
return this.doFetch(config).catch(err => {
|
||||
toast.error('Config get failed: ' + err.message);
|
||||
|
Loading…
x
Reference in New Issue
Block a user