Skip to content

Instantly share code, notes, and snippets.

@halberom
Created October 21, 2024 04:42
Show Gist options
  • Save halberom/2081e2652617a973af4db049a66f4d1f to your computer and use it in GitHub Desktop.
Save halberom/2081e2652617a973af4db049a66f4d1f to your computer and use it in GitHub Desktop.
goss troubleshooting
docker build -t test .
docker run --rm -it --name test test
# in another terminal
while true; do curl -I localhost:8080/healthz; sleep 5; done
FROM ghcr.io/goss-org/goss as goss
FROM python
COPY --from=goss /usr/bin/goss /usr/bin/goss
WORKDIR /app
COPY goss.yaml .
COPY main.py .
COPY --chmod=755 entrypoint.sh .
EXPOSE 5000
ENTRYPOINT ["./entrypoint.sh"]
#!/usr/bin/env bash
goss -g ./goss.yaml serve --loglevel ERROR &
python ./main.py
---
process:
python:
running: true
#!/usr/bin/env python
import time
import urllib.request
import urllib.error
def uptime_bot(url):
while True:
try:
_ = urllib.request.urlopen(url)
print("Website is up!")
except urllib.error.HTTPError:
print("Website is down!")
except urllib.error.URLError:
print("Website is down!")
time.sleep(5)
if __name__ == "__main__":
url = "http://www.google.com"
uptime_bot(url)
Website is up!
Website is up!
Website is up!
2024-10-21T04:41:20Z Stale cache[res], running tests
Website is up!
2024-10-21T04:41:25Z Stale cache[res], running tests
Website is up!
2024-10-21T04:41:31Z Stale cache[res], running tests
Website is up!
2024-10-21T04:41:36Z Stale cache[res], running tests
Website is up!
2024-10-21T04:41:41Z Stale cache[res], running tests
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment