Skip to content

Instantly share code, notes, and snippets.

@elliotwutingfeng
Last active February 17, 2024 06:55
Show Gist options
  • Select an option

  • Save elliotwutingfeng/4b5522fc8557301cdf326d58e8546f68 to your computer and use it in GitHub Desktop.

Select an option

Save elliotwutingfeng/4b5522fc8557301cdf326d58e8546f68 to your computer and use it in GitHub Desktop.
How to set up your own mirror for tokei web service

How to set up your own mirror for tokei web service

  • Create a free Render account
  • Go to Dashboard
  • Click on New Web Service
  • Paste https://github.com/XAMPPRocky/tokei_rs into the Enter a public repository URL field
  • Fill in these fields with the following values
    • Name : tokei
    • Environment : Rust
    • Region : <Choose the nearest region to your geographical area>
    • Build Command : cargo build --release --jobs 1
    • Start Command : cargo run --release --jobs 1
    • Leave everything else as the default; the free plan is good enough. 😄
  • Finally, click Create Web Service and wait for it to compile ⏱️

Creating your badge

Follow instructions at the tokei_rs repository; substitute tokei.rs with your Render server URL.

Known issues

Getting 403 errors with ghcr.io?

In deploy.yml, sometimes the default ${{ secrets.GITHUB_TOKEN }} may not work well with ghcr.io.

A workaround would be to fork tokei_rs, create a GitHub Personal Access Token with write:packages access enabled, no expiry date, and add it as a secret to your fork (e.g. ${{ secrets.PERSONAL_ACCESS_TOKEN }}).

Deploy your fork instead of https://github.com/XAMPPRocky/tokei_rs to Render.

Render.com web services on the free plan are automatically spun down after 15 minutes of inactivity

You can keep the web service alive by making a GET request every 10 minutes to your tokei web service.

This can be done with a Raspberry Pi or similar low-powered computer, curl, and crontab.

Credits

XAMPPRocky/tokei#881 (comment) by https://github.com/ekzhang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment