Skip to content

Commit 7d6f80d

Browse files
committed
app 057
1 parent 59d7c3e commit 7d6f80d

3 files changed

Lines changed: 216 additions & 76 deletions

File tree

.github/actions/app/action.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,8 @@ runs:
112112
113113
echo "${LOGS_SEPARATOR}"
114114
echo "Stopping any existing Gunicorn processes on port ${APP_PORT}"
115-
PID=\$(sudo lsof -ti tcp:${APP_PORT})
116-
if [ -n "$PID" ]; then
117-
echo "Killing process $PID"
118-
sudo kill -9 $PID
119-
fi
115+
PID=\$(sudo lsof -i :${APP_PORT})
116+
sudo kill -9 \$PID
120117
121118
echo "Starting Gunicorn"
122119
nohup gunicorn -w 4 -b 127.0.0.1:${APP_PORT} app:app \

.github/actions/elk/action.yaml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,20 @@ runs:
142142
MAX_RETRIES=12
143143
RETRY_COUNT=0
144144
145-
until sudo curl -s -u elastic:$ELASTIC_PASSWORD https://localhost:9200/_cluster/health \
145+
until sudo curl -s -u elastic:\$ELASTIC_PASSWORD https://localhost:9200/_cluster/health \
146146
--cacert /etc/elasticsearch/certs/http_ca.crt | grep -E -q '"status":"green"|"status":"yellow"'; do
147-
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
148-
echo "Elasticsearch cluster failed to become healthy after $((MAX_RETRIES * 5)) seconds."
147+
if [ \$RETRY_COUNT -ge \$MAX_RETRIES ]; then
148+
echo "Elasticsearch cluster failed to become healthy after \$((MAX_RETRIES * 5)) seconds."
149149
echo "Attempting to restart Elasticsearch..."
150150
sudo systemctl restart elasticsearch
151151
152-
# Optional: wait and re-check after restart
153-
sleep 10
152+
sleep 30
154153
RETRY_COUNT=0 # Reset count to re-check after restart
155154
MAX_RETRIES=6 # Give fewer retries after restart
156155
else
157-
echo "Waiting for Elasticsearch to become healthy... (${RETRY_COUNT}/${MAX_RETRIES})"
156+
echo "Waiting for Elasticsearch to become healthy... (\${RETRY_COUNT}/\${MAX_RETRIES})"
158157
sleep 5
159-
RETRY_COUNT=$((RETRY_COUNT + 1))
158+
RETRY_COUNT=\$((RETRY_COUNT + 1))
160159
fi
161160
done
162161
rm elastic_password.txt
@@ -225,21 +224,20 @@ runs:
225224
MAX_RETRIES=12
226225
RETRY_COUNT=0
227226
228-
until sudo curl -s -u elastic:$ELASTIC_PASSWORD https://localhost:9200/_cluster/health \
227+
until sudo curl -s -u elastic:\$ELASTIC_PASSWORD https://localhost:9200/_cluster/health \
229228
--cacert /etc/elasticsearch/certs/http_ca.crt | grep -E -q '"status":"green"|"status":"yellow"'; do
230-
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
231-
echo "Elasticsearch cluster failed to become healthy after $((MAX_RETRIES * 5)) seconds."
229+
if [ \$RETRY_COUNT -ge \$MAX_RETRIES ]; then
230+
echo "Elasticsearch cluster failed to become healthy after \$((MAX_RETRIES * 5)) seconds."
232231
echo "Attempting to restart Elasticsearch..."
233232
sudo systemctl restart elasticsearch
234233
235-
# Optional: wait and re-check after restart
236-
sleep 10
234+
sleep 30
237235
RETRY_COUNT=0 # Reset count to re-check after restart
238236
MAX_RETRIES=6 # Give fewer retries after restart
239237
else
240-
echo "Waiting for Elasticsearch to become healthy... (${RETRY_COUNT}/${MAX_RETRIES})"
238+
echo "Waiting for Elasticsearch to become healthy... (\${RETRY_COUNT}/\${MAX_RETRIES})"
241239
sleep 5
242-
RETRY_COUNT=$((RETRY_COUNT + 1))
240+
RETRY_COUNT=\$((RETRY_COUNT + 1))
243241
fi
244242
done
245243
@@ -268,6 +266,7 @@ runs:
268266
echo "\$LOGSTASH_API_KEY_JSON" > logstash_api_key.json
269267
gpg --batch --yes --passphrase "$GPG_PASSPHRASE" --symmetric --cipher-algo AES256 logstash_api_key.json
270268
rm logstash_api_key.json
269+
rm elastic_password.txt
271270
272271
echo "restarting logstash"
273272
sudo systemctl restart logstash
@@ -289,7 +288,7 @@ runs:
289288
# echo "$API_KEY_ID" | sudo /usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash add ES_API_KEY_ID --stdin
290289
# echo "$API_KEY_SECRET" | sudo /usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash add ES_API_KEY_SECRET --stdin
291290
292-
rm elastic_password.txt
291+
#rm elastic_password.txt
293292
else
294293
echo "Logstash already installed."
295294
echo "restarting logstash"
@@ -352,29 +351,38 @@ runs:
352351
353352
#checks
354353
sleep 20
354+
echo "${LOGS_SEPARATOR}"
355+
echo "checking cluster health to check elasticsearch status"
356+
echo "decrypting elastic password"
357+
gpg --batch --yes --passphrase "$GPG_PASSPHRASE" --decrypt elastic_password.txt.gpg > elastic_password.txt
358+
ELASTIC_PASSWORD=\$(< elastic_password.txt)
359+
echo "checkinh health"
355360
MAX_RETRIES=12
356361
RETRY_COUNT=0
357362
358-
until sudo curl -s -u elastic:$ELASTIC_PASSWORD https://localhost:9200/_cluster/health \
363+
until sudo curl -s -u elastic:\$ELASTIC_PASSWORD https://localhost:9200/_cluster/health \
359364
--cacert /etc/elasticsearch/certs/http_ca.crt | grep -E -q '"status":"green"|"status":"yellow"'; do
360-
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
361-
echo "Elasticsearch cluster failed to become healthy after $((MAX_RETRIES * 5)) seconds."
365+
if [ \$RETRY_COUNT -ge \$MAX_RETRIES ]; then
366+
echo "Elasticsearch cluster failed to become healthy after \$((MAX_RETRIES * 5)) seconds."
362367
echo "Attempting to restart Elasticsearch..."
363368
sudo systemctl restart elasticsearch
364369
365-
# Optional: wait and re-check after restart
366-
sleep 10
370+
sleep 30
367371
RETRY_COUNT=0 # Reset count to re-check after restart
368372
MAX_RETRIES=6 # Give fewer retries after restart
369373
else
370-
echo "Waiting for Elasticsearch to become healthy... (${RETRY_COUNT}/${MAX_RETRIES})"
374+
echo "Waiting for Elasticsearch to become healthy... (\${RETRY_COUNT}/\${MAX_RETRIES})"
371375
sleep 5
372-
RETRY_COUNT=$((RETRY_COUNT + 1))
376+
RETRY_COUNT=\$((RETRY_COUNT + 1))
373377
fi
374378
done
375-
379+
rm elastic_password.txt
380+
echo "cluster healthy"
376381
sudo systemctl restart logstash
377382
sudo systemctl restart kibana
383+
384+
echo "${LOGS_SEPARATOR}"
385+
echo "service status checks"
378386
sudo systemctl status elasticsearch
379387
sudo systemctl status logstash
380388
sudo systemctl status kibana

0 commit comments

Comments
 (0)