-
Notifications
You must be signed in to change notification settings - Fork 2
Running as a Service
You can run github-hetzner-runners as a service.
✋ Note: | In order to install the service, the user who installed the module must have sudo privileges. |
---|
After installation, you can use service install and service uninstall commands to install and uninstall the service.
✋ Note: | The options that are passed to the github-hetzner-runners <options> service install command will be the same options with which the service will be executed. |
---|
export GITHUB_TOKEN=ghp_...
export GITHUB_REPOSITORY=testflows/github-hetzner-runners
export HETZNER_TOKEN=GJzdc...
github-hetzner-runners service install
The /etc/systemd/system/github-hetzner-runners.service file is created with the following content.
✋ Note: |
The service will use the User and the Group of the user executing the program. |
---|---|
/etc/systemd/system/github-hetzner-runners.service: |
[Unit] Description=Autoscaling GitHub Actions Runners After=multi-user.target [Service] User=1000 Group=1000 Type=simple Restart=always Environment=GITHUB_TOKEN=ghp_... Environment=GITHUB_REPOSITORY=testflows/testflows-github-hetzner-runners Environment=HETZNER_TOKEN=GJ.. ExecStart=/home/user/.local/lib/python3.10/site-packages/testflows/github/hetzner/runners/bin/github-hetzner-runners --workers 10 --max-powered-off-time 20 --max-unused-runner-time 120 --max-runner-registration-time 60 --scale-up-interval 10 --scale-down-interval 10 [Install] WantedBy=multi-user.target |
If you want to modify service program options, you can stop the service, edit the /etc/systemd/system/github-hetzner-runners.service file by hand, then reload the service daemon, and start the service back up.
github-hetzner-runners service stop
sudo vim /etc/systemd/system/github-hetzner-runners.service
sudo systemctl daemon-reload
github-hetzner-runners service starts
After installation, you can check the status of the service using the service status command.
github-hetzner-runners service status:
service status: |
● github-hetzner-runners.service - Autoscaling GitHub Actions Runners Loaded: loaded (/etc/systemd/system/github-hetzner-runners.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2023-07-24 14:38:33 EDT; 1h 31min ago Main PID: 66188 (python3) Tasks: 3 (limit: 37566) Memory: 28.8M CPU: 8.274s CGroup: /system.slice/github-hetzner-runners.service └─66188 python3 /usr/local/bin/github-hetzner-runners --workers 10 --max-powered-off-time 20 --max-unused-runner-time 120 --max-> Jul 24 14:38:33 user-node systemd[1]: Started Autoscaling GitHub Actions Runners. Jul 24 14:38:33 user-node github-hetzner-runners[66188]: 07/24/2023 02:38:33 PM INFO MainThread main 🍀 Logging in to Hetzner > Jul 24 14:38:33 user-node github-hetzner-runners[66188]: 07/24/2023 02:38:33 PM INFO MainThread main 🍀 Logging in to GitHub Jul 24 14:38:33 user-node github-hetzner-runners[66188]: 07/24/2023 02:38:33 PM INFO MainThread main 🍀 Getting repository vza> Jul 24 14:38:33 user-node github-hetzner-runners[66188]: 07/24/2023 02:38:33 PM INFO MainThread main 🍀 Creating scale up serv> Jul 24 14:38:33 user-node github-hetzner-runners[66188]: 07/24/2023 02:38:33 PM INFO MainThread main 🍀 Creating scale down se> lines 1-16/16 (END) |
---|
You can start and stop the service using the service start and service stop commands as follows:
github-hetzner-runners service starts
github-hetzner-runners service stop
or using service system utility
sudo service github-hetzner-runners start
sudo service github-hetzner-runners stop
✋ Note: | The service stop command will send the SIGINT signal to the github-hetzner-runners process and will wait for the program to perform a clean shutdown, which includes stopping scale up and scale down loops. Given that the github-hetzner-runners program might be in the middle of configuring servers, the service stop command might take sometime to complete. |
---|
You can get the log for the service using the service log command.
Use the -f, --follow option to follow the log journal. By default, the last 1000 lines will be shown and then the log will be followed, and the new messages will be displayed as they are added to the log.
github-hetzner-runners service log -f
followed log: |
github-hetzner-runners service log -f Using config file: /home/user/.github-hetzner-runners/config.yaml 18:11:49 api_watch INFO 🍀 Consumed 0 calls in 60 sec, 5000 calls left, reset in 3599 sec 18:12:49 api_watch INFO 🍀 Logging in to GitHub 18:12:49 api_watch INFO 🍀 Checking current API calls consumption rate 18:12:49 api_watch INFO 🍀 Consumed 0 calls in 60 sec, 5000 calls left, reset in 3599 sec 18:13:49 api_watch INFO 🍀 Logging in to GitHub 18:13:49 api_watch INFO 🍀 Checking current API calls consumption rate 18:13:50 api_watch INFO 🍀 Consumed 0 calls in 60 sec, 5000 calls left, reset in 3599 sec ... |
---|
You can dump the full log by omitting the -f, --follow option.
github-hetzner-runners service log
full log: |
Using config file: /home/user/.github-hetzner-runners/config.yaml 09:44:28 http_cache INFO 🍀 Enabling HTTP cache at /tmp/tmp60wo30tc/http_cache 09:44:28 main INFO 🍀 Logging in to Hetzner Cloud 09:44:28 main INFO 🍀 Logging in to GitHub 09:44:28 main INFO 🍀 Getting repository testflows/testflows-github-hetzner-runners 09:44:28 main INFO 🍀 Checking if default image exists 09:44:29 main INFO 🍀 Checking if default location exists 09:44:29 main INFO 🍀 Checking if default server type exists 09:44:29 main INFO 🍀 Getting server prices 09:44:30 main INFO 🍀 Checking if SSH key exists ... |
---|
You can use the -c name[:width][,...], --columns name[:width][,...] option to specify a comma-separated list of columns to include in the output as well as their optional width.
For example,
github-hetzner-runners service log -f -c time,message:50
Using config file: /home/user/.github-hetzner-runners/config.yaml Using config file: /home/user/.github-hetzner-runners/config.yaml 18:13:50 🍀 Consumed 0 calls in 60 seconds, 5000 calls left, reset in 3599 sec 18:14:50 🍀 Logging in to GitHub 18:14:50 🍀 Checking current API calls consumption rate ...
By default, the following columns are available unless you redefine the logger_format in your configuration file:
- date
- time
- level
- interval
- funcName
- threadName
- run_id
- job_id
- server_name
- message
You can select the number of lines you would like to output from the log using the -n [+]number, --lines [+]number option. With the --follow the default is 10.
You can use the + before the number to output a log starting with the specified line number.
For example,
github-hetzner-runners service log -n 50
github-hetzner-runners service log -n +100
github-hetzner-runners service log -f -n 1
By default, the log is processed and broken up into columns based on the logger_format configuration. You can output the raw log by specifying the --raw option.
Developed and maintained by the TestFlows team.
- Home
- Installation
- Quick Start
- Getting Started Tutorial
- Basic Configuration
- Specifying the Maximum Number of Runners
- Specifying the Maximum Number of Runners Used in Workflow a Run
- Recycling Powered‐Off Servers
- Skipping Jobs
- Using Custom Label Prefix
- Jobs That Require the Docker Engine
- Specifying The Runner Type
- Specifying The Runner Location
- Specifying The Runner Image
- Specifying The Custom Runner Server Setup Script
- Specifying The Custom Runner Server Startup Script
- Disabling Setup or Startup Scripts
- Specifying Standby Runners
- Specifying Logger Configuration
- Listing All Current Servers
- Opening The SSH Client To The Server
- Deleting All Runners and Their Servers
- Using a Configuration File
- Specifying SSH Key
- Specifying Additional SSH Keys
- Running as a Service
- Running as a Cloud Service
- Scaling Up Runners
- Scaling Down Runners
- Handling Failing Conditions
- Meta Labels
- Estimating Costs
- Listing Images
- Deleting Images
- Creating Custom Images
- Program Options