# [poudriere] graceful handling of temporary connectivity loss?



## zirias@ (Jan 21, 2022)

My current ISP enforces a reconnect every 24 hours. Yes, that's really stupid nowadays, and I had quite some fight with their "support", debunking any explanation they tried to give me _why_ this would be "necessary", but to no avail. I was offered the right to immediately terminate the contract. I decided to keep it anyways for a while... well, whatever, that's the situation, and AFAIK, there are still lots of ISPs employing that practice.

The problem is, this results in several seconds each night without internet connectivity.

Now, it sometimes happens to exactly hit the "fetch" phase of a port during a `poudriere bulk` run. That's annoying cause it immediately fails this build.

My question is: Is there an option, either in poudriere or in the ports framework, that would allow to add some retries to fetching?


----------



## covacat (Jan 21, 2022)

override FETCH_CMD with a shell script ?


----------



## zirias@ (Jan 21, 2022)

covacat might be a suitable idea to "solve" this myself. It won't cover everything (custom fetch target?), but would be a start 

edit: after reading bsd.port.mk, it probably makes more sense to override `FETCH_BINARY`


----------



## covacat (Jan 21, 2022)

Zirias said:


> edit: after reading bsd.port.mk, it probably makes more sense to override `FETCH_BINARY`


probably yes
you catch some extra fetch flags

```
#!/bin/sh
H=$(date +%H)
RETR=1
SLEEP=10
FETCH=/usr/bin/fetch
# change this to only try retries  at night ?
# [ $H -gt 24 ] && exec $FETCH $@

while [  $RETR  -ge 0 ]
 do
 $FETCH $@
 FETCH_EXIT=$?
 [ $FETCH_EXIT -eq 0 ] && exit 0
 [ $RETR -eq 0 ] && exit $FETCH_EXIT
 echo $RETR retries left
 echo SLEEPING $SLEEP && sleep $SLEEP
 RETR=$(($RETR - 1))
 done
```
something like this seem to work for basic stuff


----------



## zirias@ (Jan 21, 2022)

I was about to hack together something similar, but am still in a meeting (day job) ... well, thanks, will give it a try


----------

