Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Enhancement: configure pglet server options via config file #73

Closed
c-nv-s opened this issue Feb 25, 2021 · 13 comments
Closed

Enhancement: configure pglet server options via config file #73

c-nv-s opened this issue Feb 25, 2021 · 13 comments
Milestone

Comments

@c-nv-s
Copy link
Contributor

c-nv-s commented Feb 25, 2021

At present, the current pglet limitations are listed as:
Pages

  • {account_name} can be anything.
  • Anonymous client can create up to 10 pages per hour.
  • Once a page is created from a certain IP it must be updated from the same IP; otherwise page name could not be reused untill the page is expired and its name reclaimed.
  • Shared page lifetime is limited to 6 hours since the last time it was updated.
  • App page lifetime is limited to 60 minutes since the last time any app session was updated.

Sessions

  • Anonymous client can create up to 10 app sessions per hour.
  • App page session lifetime is limited to 60 minutes since the last time it was accessed or updated.
  • When a host client serving an app page is disconnected all app sessions are immediately invalidated. That's a convenient "feature" during beta-testing because when user restarts the app and refreshes the page in the browser they'll start a new session.

Page size

  • Maximum size of a page or app session is limited to 1 MB.

As an administrator running a pglet server it would be very useful if some/all of these options could be configured via a config file.

The value added would be that it would allow an administrator more flexibility and control over the performance/constraints that the pglet app can offer according to the resources of the server it is on.

As a possible solution I would suggest something like https://github.com/spf13/viper as a mature solution for golang app config via config files and environment variables. It supports multiple file formats for your config files e.g. JSON, YAML, INI etc.

This would also allow users to deploy different configs for e.g. dev/test/staging/prod environments

@FeodorFitsner
Copy link
Contributor

It's already possible to configure all these settings via environment variables: https://github.com/pglet/pglet/blob/master/internal/config/config.go#L10-L31

I will look into viper though to provide alternative configuration sources - thanks for the link!

What platform are you going to deploy Pglet Server on? Environment variables play quite nicely with Pglet Docker container if it's Linux.

@c-nv-s
Copy link
Contributor Author

c-nv-s commented Feb 26, 2021

Yes the ENV variables method is definitely useful and needed.
I only suggested adding config files as well as sometimes it can make things easier... for example if you are deploying to IoT devices for kiosks or similar, you can just push a config file to each of them and then restart the app.

I would only really be using pglet on x86 or ARM linux boxes.

By the way, was I seeing things or was there a PGLET_AUTH environment variable that was available?
I thought its purpose was to set it on the server and then only scripts that presented it were able to utilize the pglet server? basically like a kind of API Key?

@FeodorFitsner
Copy link
Contributor

Very well, that makes sense.

I've added another issue #74 to implement auth token check. Will be added this week.

@FeodorFitsner
Copy link
Contributor

@c-nv-s I'm thinking about the following solution:

  • Configuration file format - YAML
  • Configuration can be overwritten via environment variables with PGLET_ prefix.
  • Configuration file location on Linux/Unix (source):
    • /etc/pglet/config.yml (system-wide)
    • $HOME/.config/pglet/config.yml (user-specific)
    • ./config.yml (current directory)
  • Configuration file location on Windows:
    • $ProgramData\pglet\config.yml (system-wide)
    • $HOME\.pglet\config.yml (user-specific)
    • .\config.yml (current directory)

@c-nv-s
Copy link
Contributor Author

c-nv-s commented Feb 27, 2021

Looks good to me.
I don't use Windows so I can't give an opinion for that section.

@FeodorFitsner FeodorFitsner added this to the v0.2.3 milestone Feb 28, 2021
@FeodorFitsner
Copy link
Contributor

Configuration file template (to include into docs): https://github.com/pglet/pglet/blob/976a6b4ae90db51d25ee81745845641f79a8c9ba/config.template.yml

@FeodorFitsner
Copy link
Contributor

@c-nv-s I've added a guide for Pglet Server installation and configuration: https://pglet.io/docs/pglet-server/installation - let me know if you have any feedback or questions.

@c-nv-s
Copy link
Contributor Author

c-nv-s commented Mar 3, 2021

FYI there might be a regression that slipped in with this.
setting the config via the config file works fine.
I just tried setting the config by only using environment variables and it didn't seem to pick anything up.
I'll have to investigate more later

@FeodorFitsner
Copy link
Contributor

What variable are you trying to set?

@c-nv-s
Copy link
Contributor Author

c-nv-s commented Mar 3, 2021

I think it was

ALLOW_REMOTE_HOST_CLIENTS=true

it kept failing when the backend client was trying to connect saying it wasn't enabled
I'm busy at the moment but I'll update you later

@FeodorFitsner
Copy link
Contributor

Yep, all variables now comes with PGLET_ prefix, so it should be PGLET_ALLOW_REMOTE_HOST_CLIENTS.

@c-nv-s
Copy link
Contributor Author

c-nv-s commented Mar 3, 2021

AAaah OK... silly me haha

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants