What could be the reason for a Python script failing with "Exit Code: 0" and "Unhealthy allocations" on Fly.io, and how can I troubleshoot it? I'm just trying a host a simple python script on fly.io.
#-----python script-----#
import datetime
import time
def periodic_task():
while True:
now = datetime.datetime.now()
week_number = now.isocalendar()[1]
print(f"Week number: {week_number}")
# Sleep for a minute
time.sleep(5)
if __name__ == '__main__':
periodic_task()
#-----fly.toml file-----#
# fly.toml file generated for withered-snowflake-645 on 2023-02-05T04:28:07+05:30
app = "withered-snowflake-645"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[build]
builder = "paketobuildpacks/builder:base"
[env]
PORT = "8080"
[experimental]
auto_rollback = true
[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
#-----procfile-----#
web: python db_script.py
the error message in the console was,
==> Creating release
--> release v4 created
--> You can detach the terminal anytime without stopping the deployment
==> Monitoring deployment
Logs: https://fly.io/apps/withered-snowflake-645/monitoring
1 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total]
Failed Instances
Failure #1
Instance
ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
4bdf42c6 app 4 fra run failed 1 total 2 21s ago
Recent Events
TIMESTAMP TYPE MESSAGE
2023-02-04T23:39:19Z Received Task received by client
2023-02-04T23:39:19Z Task Setup Building Task Directory
2023-02-04T23:39:24Z Started Task started by client
2023-02-04T23:39:26Z Terminated Exit Code: 0
2023-02-04T23:39:26Z Restarting Task restarting in 1.02248256s
2023-02-04T23:39:31Z Started Task started by client
2023-02-04T23:39:33Z Terminated Exit Code: 0
2023-02-04T23:39:33Z Restarting Task restarting in 1.047249935s
2023-02-04T23:39:39Z Started Task started by client
2023-02-04T23:39:41Z Terminated Exit Code: 0
2023-02-04T23:39:41Z Not Restarting Exceeded allowed attempts 2 in interval 5m0s and mode is "fail"
2023-02-04T23:39:41Z Alloc Unhealthy Unhealthy because of failed task
2023-02-04T23:39:22Z [info]Unpacking image
2023-02-04T23:39:23Z [info]Preparing kernel init
2023-02-04T23:39:24Z [info]Configuring firecracker
2023-02-04T23:39:24Z [info]Starting virtual machine
2023-02-04T23:39:24Z [info]Starting init (commit: e3cff9e)...
2023-02-04T23:39:24Z [info]Preparing to run: `/cnb/process/web` as 1000
2023-02-04T23:39:24Z [info]2023/02/04 23:39:24 listening on [fdaa:1:2a7f:a7b:b6:4bdf:42c6:2]:22 (DNS: [fdaa::3]:53)
2023-02-04T23:39:25Z [info]Starting clean up.
2023-02-04T23:39:30Z [info]Starting instance
2023-02-04T23:39:30Z [info]Configuring virtual machine
2023-02-04T23:39:30Z [info]Pulling container image
2023-02-04T23:39:31Z [info]Unpacking image
2023-02-04T23:39:31Z [info]Preparing kernel init
2023-02-04T23:39:31Z [info]Configuring firecracker
2023-02-04T23:39:31Z [info]Starting virtual machine
2023-02-04T23:39:31Z [info]Starting init (commit: e3cff9e)...
2023-02-04T23:39:31Z [info]Preparing to run: `/cnb/process/web` as 1000
2023-02-04T23:39:31Z [info]2023/02/04 23:39:31 listening on [fdaa:1:2a7f:a7b:b6:4bdf:42c6:2]:22 (DNS: [fdaa::3]:53)
2023-02-04T23:39:32Z [info]Starting clean up.
2023-02-04T23:39:37Z [info]Starting instance
2023-02-04T23:39:38Z [info]Configuring virtual machine
2023-02-04T23:39:38Z [info]Pulling container image
2023-02-04T23:39:38Z [info]Unpacking image
2023-02-04T23:39:38Z [info]Preparing kernel init
2023-02-04T23:39:38Z [info]Configuring firecracker
2023-02-04T23:39:39Z [info]Starting virtual machine
2023-02-04T23:39:39Z [info]Starting init (commit: e3cff9e)...
2023-02-04T23:39:39Z [info]Preparing to run: `/cnb/process/web` as 1000
2023-02-04T23:39:39Z [info]2023/02/04 23:39:39 listening on [fdaa:1:2a7f:a7b:b6:4bdf:42c6:2]:22 (DNS: [fdaa::3]:53)
2023-02-04T23:39:40Z [info]Starting clean up.
--> v4 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v5
--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort
- I tried procfile with
worker: python db_script.py
it didn't work. requirement.txt
file with and without codes of dependencies didn't work.- By increasing the time of
time.sleep()
didn't work either.(tried for 5sec, 1hr) - I want to know what is the reason for this error and how to solve it.
Can someone please help me troubleshoot this issue and find a solution to get my task running on Fly.io? Any help is greatly appreciated. Thank you!