Use cloud functions
This would allow users to setup/start/stop rigs from a wider range of clients, without needing to launch a bash shell, e.g.
- webhook from a discord bot, IFTTT button, google-oauth'd webpage
- ~~pub/sub handlers to deal with preemption and maintainence reported by #32~~ not nessessary, boot disks persist just fine when terminated/stopped, providing you don't delete/replace the instance.
do you have language in mind for this?
Probably nodejs, but I'm not sure when I'll get a chance to dig into this.
Open to suggestions :)
Just curious, instead of using cloud functions to cleanup upon shutdown, how about using gcloud alpha cloud-shell + nohup as an alternative to run the cleanup script(snapshots and so on).
This can help avoid the cloud function compute cost, although it would have the other benefits stated in op.
The idea of using cloud functions was to start handling each of the stateless activities that gcloudrig currently provides (setup, launch, shutdown, snapshot), ultimately leading way for a cloud-native port that once setup, you could trigger from your web browser. The cost of compute for cloud functions would be negligible (especially when weighed against the cost of running the rig itself).
But that's a lot of work... so until then I'll do exactly what you just said, over in #32 👍
Maybe instead of cloud functions, we could use Google Cloud Run with a custom docker image that incorporates the gcloud cli and node docker images. Whenever the node server gets hit, it simply executes the respective shell scripts, so we don't have to rewrite all the bash scripts in javascript
I know this is old, but I agree with @SwiftWinds. I think it is easiest to build off of the already good bash scripts you have and just wrap it in an express server that calls the scripts. It could serve a simple webpage to login and pipe the output over sockets to monitor from the frontend?
I could get started if you think this is something to pursue? I have some experience with Cloud Run and things like this.
I think this is an interesting approach so I am getting started here: https://github.com/oschwartz10612/gcloudrig/tree/cloud-run/api
Feel free to contribute or tell me what I am doing wrong.
Nice work, @oschwartz10612! Unfortunately, I currently have little time in my schedule to contribute, but best of luck getting the server working!