Git Product home page Git Product logo

psgallery-module-downloads's Introduction

Docker Pulls GitHub repo

Prerequisites

  • An InfluxDB install.

Dependencies

  1. Create a new InfluxDB bucket.
  2. Create an api token in InfluxDB with WRITE access to your newly made bucket.

Setup and installation

You can run the image either by using docker run or docker compose.

Docker compose

  1. Put this inside the docker-compose.yml file.
version: '3'
services:
  psgallery-module-downloads:
    container_name: psgallery-module-downloads
    image: norsknoobing/psgallery-module-downloads:latest
    environment:
      - PSGALLERY_PROFILE_NAME=
      - INFLUX_HOST=
      - INFLUX_BUCKET=
      - INFLUX_ORG=
      - INFLUX_TOKEN=
  1. Add all your ENV_VARS values after each equals sign.
  2. Run the container by using docker compose up -d in the directory where your docker-compose.yml file is located.

Environmental variables

Variable Description Required
PSGALLERY_PROFILE_NAME The username of your PSGallery profile.
INFLUX_HOST The hostname of your InfluxDB installation, including the port if applicable. I.e. 192.168.86.10:8086, https://influxdb.example.com, or http://influxdb:8086. It's important that you add the protocol when using a hostname, like in the last example.
INFLUX_BUCKET The name of the InfluxDB bucket that the script should use.
INFLUX_ORG The name or ID of your InfluxDB org.
INFLUX_TOKEN An InfluxDB API token that has WRITE access to the bucket that you specified.

psgallery-module-downloads's People

Contributors

norsknoobing avatar

Watchers

 avatar

psgallery-module-downloads's Issues

Improve ENV var passthrough to cron

Possibly find a better way to get the ENV_VARS into the cron PowerShell script. Instead of using the current export of each ENV var in the shell script, and then using it as a source in cron.

Check for requirements and improvements to logging

  1. Add checks to see if all required ENV variables are provided. Stop the container, and log error if they're not provided.
  2. Check if ENV inputs are valid. Stop the container, and log error if they're not valid.
  • Check for connection to INFLUX_HOST.
  • Check if INFLUX_ORG is correct.
  • Check if INFLUX_BUCKET exists.
  • Check if INFLUX_TOKEN is valid.
  • Check if PSGALLERY_PROFILE_NAME is an actual PSGallery account, with public modules.
  1. Add logging into docker log.
  • Startup complete, first run scheduled in TIMESTAMP (mins. and secs.).
  • Next run TIMESTAMP, after completing a run.
  • Log stdout of PowerShell script. (stderr seems to work already)

Improve prereq InfluxDB documentation

Add tutorial on how to setup InfluxDB (create or link to documentation).

  • docker-compose.yml setup for Influx.
  • Initial config of Influx.
  • Create a bucket.
  • Create an API token with limited permissions.
  • Query data from InfluxDB. (data explorer)

Resource temporarily unavailable

Occasionally you can get an error that says:

2023-11-23T03:00:34.747960818Z Invoke-WebRequest: /scripts/Get-ModuleDownloads.ps1:10
2023-11-23T03:00:34.747985537Z Line |
2023-11-23T03:00:34.747989577Z   10 |      $ModulePage = ((Invoke-WebRequest -Uri $ModuleURI | ConvertFrom-H2023-11-23T03:00:34.747993495Z      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-11-23T03:00:34.747996886Z      | Resource temporarily unavailable

When this happens, the script won't get a number for the downloads, and therefore it would use the previous download number. I think the best way to solve this is to just not run the API call to Influx, if the $ModuleDownloads variable is not set in the current run.

There are two ways to fix this.

  1. Set the $ModuleDownloads variable to $null at the start of the ForEach.
  2. Use a function inside the ForEach.

The first option would be the easiest, but the second seems more professional and better in general.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.