go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.08k stars 5.41k forks source link

Ability to send WOL (magic) packet to an act_runner server #26993

Open jiriks74 opened 1 year ago

jiriks74 commented 1 year ago

Feature Description

Since Gitea is quite easy to run I'm running it on my Raspberry Pi 4.

The problem is that I want to run Gitea (Github) Actions on my code but I don't think that my RPi4 can take it (I'm running more services than Gitea on it).

I'd run it on a more powerful amd64 based server but it wouldn't be cost efficient when the server would be IDLEing most of the time.

The solution for me would be for Gitea to send a WOL packet when checking if the runner is online (I think that this function is relevant) ping the server eg. every 5 seconds until it either turns on and becomes available or maximum defined time has elapsed.

I'll try to familiarize myself with Go to help out but I can't promise anything as I really haven't been working with codebases this big.

Screenshots

No response

lunny commented 1 year ago

You can run act_runner on your developer machine.

wxiaoguang commented 1 year ago

I read your message in Discord.

I think your case is quite special and maybe it wouldn't be implemented in Gitea as a general feature (too many details)

But I think you can try to implement by some of these approaches:

  1. Modify the Gitea's code, just add a command run : wakeonlan MAC:ADDR:... when Gitea received your repository's push, you can check the "notification" related functions.
  2. Add a custom webhook, let it run wakeonlan MAC:ADDR:... command if your repositories get pushed. You don't need to modify or compile Gitea by yourself.

It doesn't need to "ping server" or "wait for amount of time", because Gitea doesn't "send jobs", instead, the action runners pull the jobs.

And wakeonlan / WOL is quite cheap, it only sends a small UDP packet, so it's safe and convenient to always send such WOL packet, no need to "ping" or "wait.

jiriks74 commented 1 year ago

Thanks for clarification! I'll bodge my way to do this for me, but I thought that if I managed to this somewhat properly then some other people could use it. I know that many poeple use the RPi to run their small servers and they could then use their eg. main pc to run the actions.

Now I figured out a solution to run actions without WOL (I used my free Oracle compute instance) but it's running arm64 so I'll have some problems running actions ported from Github or getting amd64 binaries without modifying my build scripts (developing on amd64 but the server would build it on arm64). I'll see what options I have for that.

Anyways, thanks for the reply! I'll probably start a small, local, python web server listening for the webhooks and when they're recieved it'll start the server.

jiriks74 commented 1 year ago

You can run act_runner on your developer machine.

The problem with that is when I'm not at home I use my old ThinkPak T61 for dev work. And if you know what kind of machine that is then you know that it can't really handle projects larger than Hello World. I'll be getting a better one soon, I hope, but till then I'll have to figure out something else.