hitrov / oci-arm-host-capacity

This script allows to bypass Oracle Cloud Infrastructure 'Out of host capacity' error immediately when additional OCI capacity will appear in your Home Region / Availability domain.
MIT License
899 stars 449 forks source link

Use exit codes instead of return to improve control flow #115

Open purefns opened 5 months ago

purefns commented 5 months ago

First of all, I just want to thank you for the work you have put into making this great tool. It helped me finally get a server on Oracle this morning! I have been trying for months so I am incredibly grateful.

I would like to share a small improvement that I think improves the experience a little bit. If you replace the appropriate return statements at the bottom with exit(1) you could use a command like this in a tmux session or something:

$ while true; do php ./index.php && break; done

That would just loop until the exit code is 0. Same concept as the cronjob without installing anything.

You could even do something like this in a systemd service file:

[Unit]
Description=Oracle Cloud host capacity service
After=network.target

[Service]
Type=oneshot
ExecStart=test ! -e /tmp/flag && /usr/bin/php /home/user/index.php
ExecStop=touch /tmp/flag; noti # get a notification!
Restart=on-failure

[Install]
WantedBy=default.target
RequiredBy=network.target
...

Please let me know if you need anything else from me. Thank you again for sharing this tool!