Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
segler-alex committed Jan 8, 2020
2 parents 959ef47 + 244dfcb commit d48627a
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 34 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.6.1] 2020-01-08
### Added
- Prometheus docs

### Fixed
- SQL error in endpoint /checks?seconds=x
- Database column mixup for state and language

### Changed
- Run as non root user in docker by default

## [0.6.0] - 2020-01-06
### Added
- Changelog
Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Radio-Browser Server with REST API"
license = "agpl-3.0"
name = "radiobrowser-api-rust"
readme = "README.md"
version = "0.6.0"
version = "0.6.1"
edition = "2018"

[dependencies]
Expand Down
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ RUN cargo build --release

FROM ubuntu:bionic
EXPOSE 8080
RUN apt-get update && apt-get install -y libssl1.1 && rm -rf /var/lib/apt/lists/*
RUN groupadd -r radiobrowser && \
useradd --no-log-init -r -g radiobrowser radiobrowser && \
apt-get update && \
apt-get install -y libssl1.1 && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /usr/lib/radiobrowser/static/ && \
mkdir -p /var/log/radiobrowser/ && \
chown -R radiobrowser:radiobrowser /var/log/radiobrowser/
COPY --from=0 /root/target/release/radiobrowser-api-rust /usr/bin/
COPY --from=0 /root/static/ /root/static/
COPY --from=0 /root/static/ /usr/lib/radiobrowser/static/
COPY --from=0 /root/radiobrowser.toml /etc/radiobrowser.toml
ENV STATIC_FILES_DIR=/root/static/
ENV STATIC_FILES_DIR=/usr/lib/radiobrowser/static/
USER radiobrowser:radiobrowser
CMD [ "radiobrowser-api-rust", "-f", "/etc/radiobrowser.toml"]
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# radiobrowser-api-rust
This is the radio browser server part providing the API on http://www.radio-browser.info

This is the radio browser server part providing the API on the second level servers for http://www.radio-browser.info

The server addresses are:
* https://de1.api.radio-browser.info
* https://fr1.api.radio-browser.info
* https://nl1.api.radio-browser.info

The main server on http://www.radio-browser.info still has an older version running which will not be upgraded anymore.

Send me feature requests, bug reports or extend it yourself. I license it freely, you could also start your own server if you wish.

Expand Down Expand Up @@ -105,4 +113,4 @@ docker-compose up --abort-on-container-exit
```bash
cargo install cargo-deb
cargo deb # run this in your Cargo project directory
```
```
2 changes: 1 addition & 1 deletion docker-compose-traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.2"
services:
api:
build: ./
image: segleralex/radiobrowser-api-rust:0.6.0
image: segleralex/radiobrowser-api-rust:0.6.1
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`${SOURCE}`)"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.0"
services:
api:
build: ./
image: segleralex/radiobrowser-api-rust:0.6.0
image: segleralex/radiobrowser-api-rust:0.6.1
deploy:
replicas: 1
networks:
Expand Down
2 changes: 1 addition & 1 deletion radiobrowser.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ database = "mysql://radiouser:password@localhost/radio"
#static-files-dir = "/usr/local/share/radiobrowser"
static-files-dir = "./static"
## Log file path
log-files-dir = "/var/log/radiobrowser/"
log-dir = "/var/log/radiobrowser/"

## Listening IP
listen-host = "127.0.0.1"
Expand Down
8 changes: 4 additions & 4 deletions src/db/db_mysql/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ impl From<Row> for StationItem {
tags: row.take_opt("Tags").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
country: row.take_opt("Country").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
countrycode: row.take_opt("CountryCode").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
state: row.take_opt("Language").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
language: row.take_opt("Subcountry").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
state: row.take_opt("Subcountry").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
language: row.take_opt("Language").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
votes: row.take_opt("Votes").unwrap_or(Ok(0)).unwrap_or(0),
lastchangetime: row.take_opt("CreationFormated").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
homepage: row.take_opt("Homepage").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
Expand All @@ -75,8 +75,8 @@ impl From<Row> for StationHistoryItem {
tags: row.take_opt("Tags").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
country: row.take_opt("Country").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
countrycode: row.take_opt("CountryCode").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
state: row.take_opt("Language").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
language: row.take_opt("Subcountry").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
state: row.take_opt("Subcountry").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
language: row.take_opt("Language").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
votes: row.take_opt("Votes").unwrap_or(Ok(0)).unwrap_or(0),
lastchangetime: row.take_opt("CreationFormated").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
homepage: row.take_opt("Homepage").unwrap_or(Ok("".to_string())).unwrap_or("".to_string()),
Expand Down
2 changes: 1 addition & 1 deletion src/db/db_mysql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ impl DbConnection for MysqlConnection {
let table_name = if include_history { "StationCheckHistory" } else { "StationCheck" };
let where_seconds = if seconds > 0 {
format!(
"TIMESTAMPDIFF(SECOND,CheckTime,now())<{seconds}",
"AND TIMESTAMPDIFF(SECOND,CheckTime,now())<{seconds}",
seconds = seconds
)
} else {
Expand Down
51 changes: 50 additions & 1 deletion static/docs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</li>
<li><a class="dropdown-item" href="#Server_stats">Server stats</a></li>
<li><a class="dropdown-item" href="#Server_mirrors">Server mirrors</a></li>
<li><a class="dropdown-item" href="#Server_prometheus">Prometheus monitoring</a></li>
</ul>
</li>
<li class="nav-item dropdown">
Expand Down Expand Up @@ -881,6 +882,7 @@
<div class="jumbotron mt-2 shadow p-3 mb-5" id="Playable_station_url">
<h1 class="display-4">Playable station URL</h1>
<p class="lead">Returns the playable URL for the station. Any playlist (PLS, ASX, M3U) decoding will be done for you.
A call of this endpoint will also count a click for the station!
This API call will count as a click on the station, supported output formats: JSON, XML ,PLS ,M3U</p>
<hr class="my-4">
<div class="h5">Syntax:</div>
Expand All @@ -898,7 +900,7 @@
{
"ok": "true",
"message": "retrieved station url",
"id": "123",
"stationuuid": "9617a958-0601-11e8-ae97-52543be04c81",
"name": "Station name",
"url": "http://this.is.an.url"
}
Expand Down Expand Up @@ -1489,6 +1491,53 @@
<ul class="list-unstyled ml-4">
<li><a href="{{ API_SERVER }}/json/servers" target="_blank">{{ API_SERVER }}/json/servers</a></li>
</ul>
</div>

<div class="jumbotron mt-2 shadow p-3 mb-5" id="Server_prometheus">
<h1 class="display-4">Prometheus monitoring</h1>
<p class="lead ">
Exporter for <a href="https://prometheus.io/">prometheus</a>. It renders internal data about the server in a specific format that is readable by the time series database prometheus.
</p>
<hr class="my-4">
<div class="h5">Syntax:</div>
<div class="syntax">
<ul class="list-unstyled ml-4">
<li>{{ API_SERVER }}/metrics</li>
</ul>
</div>
<div class="h5">Result:</div>
<div class="well well-sm bg-light border border-secondary rounded">
<pre class="mt-4">
# HELP radio_browser_clicks_last_hour Clicks in the last hour
# TYPE radio_browser_clicks_last_hour gauge
radio_browser_clicks_last_hour 0

# HELP radio_browser_stations_broken Count of stations that are broken
# TYPE radio_browser_stations_broken gauge
radio_browser_stations_broken 740

# HELP radio_browser_stations_working Count of stations that are working/usable
# TYPE radio_browser_stations_working gauge
radio_browser_stations_working 26514

# HELP radio_browser_stations_todo Count of stations that need are in the queue for checking
# TYPE radio_browser_stations_todo gauge
radio_browser_stations_todo 27254

# HELP radio_browser_stations_deletable_never_worked Count of stations that are in the list for deletion and which never worked
# TYPE radio_browser_stations_deletable_never_worked gauge
radio_browser_stations_deletable_never_worked 0

# HELP radio_browser_stations_deletable_were_working Count of stations that are in the list for deletion and which worked at some point
# TYPE radio_browser_stations_deletable_were_working gauge
radio_browser_stations_deletable_were_working 0
</pre>
</div>

<div class="h5 mt-2">Example:</div>
<ul class="list-unstyled ml-4">
<li><a href="{{ API_SERVER }}/metrics" target="_blank">{{ API_SERVER }}/metrics</a></li>
</ul>
</div>
</div>

Expand Down

0 comments on commit d48627a

Please sign in to comment.