Skip to content

Commit

Permalink
add API for checking casaos-* service status (IceWhaleTech#852)
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger Wang <tigerwang@outlook.com>
  • Loading branch information
tigerinus authored Jan 30, 2023
1 parent e8db176 commit 0bb138e
Show file tree
Hide file tree
Showing 18 changed files with 746 additions and 135 deletions.
101 changes: 101 additions & 0 deletions api/casaos/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
openapi: 3.0.3

info:
title: CasaOS API
version: v2
description: |
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_dark_night_800px.png">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_twilight_blue_800px.png">
<img alt="CasaOS" src="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_twilight_blue_800px.png">
</picture>
CasaOS API provides miscellaneous methods for different scenarios.
For issues and discussions, please visit the [GitHub repository](https://github.com/IceWhaleTech/CasaOS) or join [our Discord](https://discord.gg/knqAbbBbeX).
servers:
- url: /v2/casaos

tags:
- name: Health methods
description: |-
(TODO)
x-tagGroups:
- name: Methods
tags:
- Health methods

security:
- access_token: []

paths:
/health/services:
get:
tags:
- Health methods
summary: Get service status
description: |-
Get running status of each `casaos-*` service.
operationId: getHealthServices
responses:
"200":
$ref: "#/components/responses/GetHealthServicesOK"
"500":
$ref: "#/components/responses/ResponseInternalServerError"

components:
securitySchemes:
access_token:
type: apiKey
in: header
name: Authorization

responses:
ResponseOK:
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/BaseResponse"

ResponseInternalServerError:
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/BaseResponse"

GetHealthServicesOK:
description: OK
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/BaseResponse"
- properties:
data:
$ref: "#/components/schemas/HealthServices"

schemas:
BaseResponse:
properties:
message:
readOnly: true
description: message returned by server side if there is any
type: string
example: ""

HealthServices:
properties:
running:
type: array
items:
type: string
example: "casaos-gateway.service"
not_running:
type: array
items:
type: string
example: "casaos.service"
24 changes: 24 additions & 0 deletions api/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>CasaOS | Developers</title>

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">

<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>

<body>
<redoc spec-url='casaos/openapi.yaml' expandResponses='all' jsonSampleExpandLevel='all'></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body>

</html>
2 changes: 1 addition & 1 deletion build/sysroot/usr/lib/systemd/system/casaos.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
After=casaos-gateway.service
After=casaos-message-bus.service
ConditionFileNotEmpty=/etc/casaos/casaos.conf
Description=CasaOS Main Service

Expand Down
13 changes: 0 additions & 13 deletions build/sysroot/usr/share/casaos/shell/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -370,19 +370,6 @@ MountCIFS(){
$sudo_cmd mount -t cifs -o username=$1,password=$6,port=$4 //$2/$3 $5
}

# $1:service name
CheckServiceStatus(){
rs="`systemctl status $1 |grep -E 'Active|PID'`"
#echo "$rs"
run="`echo "$rs" |grep -B 2 'running'`"
fai="`echo "$rs" |grep -E -B 2 'failed|inactive|dead'`"
if [ "$run" == "" ]
then
echo "failed"
else
echo "running"
fi
}
UDEVILUmount(){
$sudo_cmd udevil umount -f $1
}
191 changes: 191 additions & 0 deletions codegen/casaos_api.go

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

Loading

0 comments on commit 0bb138e

Please sign in to comment.