Skip to content

Commit 0bb138e

Browse files
authored
add API for checking casaos-* service status (#852)
Signed-off-by: Tiger Wang <[email protected]>
1 parent e8db176 commit 0bb138e

File tree

18 files changed

+746
-135
lines changed

18 files changed

+746
-135
lines changed

api/casaos/openapi.yaml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
openapi: 3.0.3
2+
3+
info:
4+
title: CasaOS API
5+
version: v2
6+
description: |
7+
<picture>
8+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_dark_night_800px.png">
9+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_twilight_blue_800px.png">
10+
<img alt="CasaOS" src="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_twilight_blue_800px.png">
11+
</picture>
12+
13+
CasaOS API provides miscellaneous methods for different scenarios.
14+
15+
For issues and discussions, please visit the [GitHub repository](https://github.com/IceWhaleTech/CasaOS) or join [our Discord](https://discord.gg/knqAbbBbeX).
16+
17+
servers:
18+
- url: /v2/casaos
19+
20+
tags:
21+
- name: Health methods
22+
description: |-
23+
(TODO)
24+
25+
x-tagGroups:
26+
- name: Methods
27+
tags:
28+
- Health methods
29+
30+
security:
31+
- access_token: []
32+
33+
paths:
34+
/health/services:
35+
get:
36+
tags:
37+
- Health methods
38+
summary: Get service status
39+
description: |-
40+
Get running status of each `casaos-*` service.
41+
operationId: getHealthServices
42+
responses:
43+
"200":
44+
$ref: "#/components/responses/GetHealthServicesOK"
45+
"500":
46+
$ref: "#/components/responses/ResponseInternalServerError"
47+
48+
components:
49+
securitySchemes:
50+
access_token:
51+
type: apiKey
52+
in: header
53+
name: Authorization
54+
55+
responses:
56+
ResponseOK:
57+
description: OK
58+
content:
59+
application/json:
60+
schema:
61+
$ref: "#/components/schemas/BaseResponse"
62+
63+
ResponseInternalServerError:
64+
description: Internal Server Error
65+
content:
66+
application/json:
67+
schema:
68+
$ref: "#/components/schemas/BaseResponse"
69+
70+
GetHealthServicesOK:
71+
description: OK
72+
content:
73+
application/json:
74+
schema:
75+
allOf:
76+
- $ref: "#/components/schemas/BaseResponse"
77+
- properties:
78+
data:
79+
$ref: "#/components/schemas/HealthServices"
80+
81+
schemas:
82+
BaseResponse:
83+
properties:
84+
message:
85+
readOnly: true
86+
description: message returned by server side if there is any
87+
type: string
88+
example: ""
89+
90+
HealthServices:
91+
properties:
92+
running:
93+
type: array
94+
items:
95+
type: string
96+
example: "casaos-gateway.service"
97+
not_running:
98+
type: array
99+
items:
100+
type: string
101+
example: "casaos.service"

api/index.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<title>CasaOS | Developers</title>
6+
7+
<meta charset="utf-8" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
10+
11+
<style>
12+
body {
13+
margin: 0;
14+
padding: 0;
15+
}
16+
</style>
17+
</head>
18+
19+
<body>
20+
<redoc spec-url='casaos/openapi.yaml' expandResponses='all' jsonSampleExpandLevel='all'></redoc>
21+
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
22+
</body>
23+
24+
</html>

build/sysroot/usr/lib/systemd/system/casaos.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
After=casaos-gateway.service
2+
After=casaos-message-bus.service
33
ConditionFileNotEmpty=/etc/casaos/casaos.conf
44
Description=CasaOS Main Service
55

build/sysroot/usr/share/casaos/shell/helper.sh

-13
Original file line numberDiff line numberDiff line change
@@ -370,19 +370,6 @@ MountCIFS(){
370370
$sudo_cmd mount -t cifs -o username=$1,password=$6,port=$4 //$2/$3 $5
371371
}
372372

373-
# $1:service name
374-
CheckServiceStatus(){
375-
rs="`systemctl status $1 |grep -E 'Active|PID'`"
376-
#echo "$rs"
377-
run="`echo "$rs" |grep -B 2 'running'`"
378-
fai="`echo "$rs" |grep -E -B 2 'failed|inactive|dead'`"
379-
if [ "$run" == "" ]
380-
then
381-
echo "failed"
382-
else
383-
echo "running"
384-
fi
385-
}
386373
UDEVILUmount(){
387374
$sudo_cmd udevil umount -f $1
388375
}

codegen/casaos_api.go

+191
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)