Skip to content

Commit 437f60e

Browse files
committed
deploy wf; enable/disable redis functionality
1 parent 2403faa commit 437f60e

3 files changed

Lines changed: 72 additions & 2 deletions

File tree

.github/deploy.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy
2+
3+
on:
4+
check_run:
5+
types: [requested_action, rerequested]
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
#on:
10+
# push:
11+
# branches:
12+
# - main
13+
14+
jobs:
15+
workflow:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v1
20+
21+
- name: Upload files
22+
uses: SamKirkland/FTP-Deploy-Action@2.0.0
23+
env:
24+
FTP_SERVER: ${{ secrets.SFTP_HOST }}
25+
FTP_USERNAME: ${{ secrets.SFTP_USER }}
26+
FTP_PASSWORD: ${{ secrets.SFTP_PASS }}
27+
LOCAL_DIR: ./
28+
REMOTE_DIR: ./
29+
METHOD: sftp
30+
PORT: ${{ secrets.SFTP_PORT }}
31+
ARGS: --no-empty-dirs
32+
33+
- name: Stop the Pterodactyl server
34+
shell: bash
35+
run: |
36+
curl --request POST \
37+
--url ${{ secrets.BASE_URL }}api/client/servers/${{ secrets.SERVER_ID }}/power \
38+
--header 'Accept: application/json' \
39+
--header 'Authorization: Bearer ${{ secrets.API_KEY }}' \
40+
--header 'Content-Type: application/json' \
41+
--data '{ "signal": "stop" }'
42+
43+
- name: Kill the Pterodactyl server
44+
shell: bash
45+
run: |
46+
curl --request POST \
47+
--url ${{ secrets.BASE_URL }}api/client/servers/${{ secrets.SERVER_ID }}/power \
48+
--header 'Accept: application/json' \
49+
--header 'Authorization: Bearer ${{ secrets.API_KEY }}' \
50+
--header 'Content-Type: application/json' \
51+
--data '{ "signal": "kill" }'
52+
53+
- name: Start the Pterodactyl server
54+
shell: bash
55+
run: |
56+
curl --request POST \
57+
--url ${{ secrets.BASE_URL }}api/client/servers/${{ secrets.SERVER_ID }}/power \
58+
--header 'Accept: application/json' \
59+
--header 'Authorization: Bearer ${{ secrets.API_KEY }}' \
60+
--header 'Content-Type: application/json' \
61+
--data '{ "signal": "start" }'

config.json.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515

1616
"REDIS": {
17+
"ENABLED": 1,
1718
"HOST": "",
1819
"PASSWORD": "",
1920
"PORT": 6379,

globals.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ def append_denied_log(request: Request):
6565

6666
def set_cache(cache_key: str, data):
6767
"""Cache the data in Redis\n
68-
`Decimal` values are converted to `String`"""
68+
`Decimal` values are converted to `String`\n
69+
### Still returns `True` if Redis functionality is disabled"""
70+
if config["REDIS"]["ENABLED"] == 0:
71+
return True
72+
6973
redis_client.set(
7074
cache_key,
7175
json.dumps(data, default=json_decimal),
@@ -76,7 +80,11 @@ def set_cache(cache_key: str, data):
7680

7781

7882
def get_cache(cache_key: str):
79-
"""Try and get cached data from Redis"""
83+
"""Try and get cached data from Redis\n
84+
### Still returns `None` if Redis functionality is disabled"""
85+
if config["REDIS"]["ENABLED"] == 0:
86+
return None
87+
8088
cached_data = redis_client.get(cache_key)
8189
if cached_data:
8290
# Return cached data

0 commit comments

Comments
 (0)