Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation specifying where configuration parameters are stored would make migrating systems much easier! #257

Open
fake-name opened this issue Mar 2, 2019 · 8 comments
Labels

Comments

@fake-name
Copy link

fake-name commented Mar 2, 2019

Basically, I'm trying to migrate a pghero install from a vm into a container.

I'd like to be able to just copy a single config file across (or maybe a directory), but it seems that's not currently possible.

So far, to simply move machines:

  • Install pghero
  • Copy pghero.yml across.
  • sudo service pghero restart - Service is masked
  • <10 minutes of experimenting trying to figure out how to actually start the thing>
  • sudo pghero scale web=1 apparently actually installs the service handlers.
  • sudo service pghero restart - It works this time
  • Query stats are not being logged.

Query stats are configured via PGHERO_STATS_DATABASE_URL, but that doesn't seem to affect the config file, and I have no idea where the value you specify to it is going.

Basically, I think I'm proposing that you have one config file (or a directory of config files), and all config stuff is stored there. Right now, it appears to be scattered around in lots of places, and that makes migrating a config basically impossible.

@fake-name
Copy link
Author

MOAR DIGGING:

So pghero seems to generate a BUNCH of systemd unit files for ~~reasons~~:

  • pghero.service
  • pghero-web.service
  • pghero-web-1.service

pghero.service and pghero-web.service are both empty services that just sleep (why is this a thing). However, pghero-web-1.service is the actual service. It invokes /usr/bin/pghero. Reading that file (it's a shell script) more environment parameters are loaded from /etc/pghero/*. Mounting my old system's disk and looking in there, DATABASE_URL is exported in there.

Experimentally moving that line to the new configuration makes the space tab start working.

  • Why is it called DATABASE_URL in the config, when it's specified as PGHERO_STATS_DATABASE_URL?
  • Why isn't everything in /etc/pghero just put in pghero.yml?
  • From a platform perspective, it seems pghero.yml should probably be placed in /etc/pghero/, but I assume it's current location is a side-effect of the way the app is packaged.

@fake-name
Copy link
Author

OTOH, the duplicate indexes thing is awesome (and holy potatoes, I have a bunch of duplicate indexes).

I'm not sure why my previous install wasn't seeing them, as far as I know it should have been updating itself.

@ankane
Copy link
Owner

ankane commented Mar 6, 2019

Hey @fake-name, I think the easiest way to migrate is:

  1. Follow installation instructions
  2. Copy ENV variables or pghero.yml to new machine

@fake-name
Copy link
Author

fake-name commented Mar 6, 2019

  1. Copy ENV variables or pghero.yml to new machine

The issue was I didn't have any ENV variables (and even if I did, how would something in my .bashrc wind up getting to services?). apparently some of the config calls (sudo pghero config:set PGHERO_STATS_DATABASE_URL=..., etc...) operate by writing things to /etc/pghero/conf.d), which I don't think is mentioned anywhere in the docs.

Basically, I think the issue here is "why is there both a /etc/pghero/conf.d/* config file and /opt/pghero/config/pghero.yml"? Also, is the ENV-variables-that-are-really-a script-that's-sourced-somewhere thing specific to ruby or something? I haven't seen it elsewhere, but this is basically the only ruby project I use anywhere.

@ankane
Copy link
Owner

ankane commented Nov 6, 2019

Hey @fake-name, with the next release, you'll be able to configure everything in pghero.yml and won't need to worry about config:set. I'll leave this open for now to remember to update the docs.

@ankane ankane added the waiting label Nov 6, 2019
@prikhi
Copy link

prikhi commented Dec 5, 2019

with the next release, you'll be able to configure everything in pghero.yml

I've been writing an ansible playbook for deploying a web service that I want to use pghero with & am wondering if these changes are included in v2.4.1 & where the pghero.yml file should be placed(for the Ubuntu builds).

@ankane
Copy link
Owner

ankane commented Dec 6, 2019

Hey @prikhi, v2.4.1 includes the changes and the file can be placed at /opt/pghero/config/pghero.yml on Ubuntu.

@ankane
Copy link
Owner

ankane commented Dec 6, 2019

However, I'd use the official command to set it rather than placing it there directly. https://github.com/ankane/pghero/blob/master/guides/Linux.md#multiple-databases

cat pghero.yml | sudo pghero run sh -c "cat > config/pghero.yml"

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

No branches or pull requests

3 participants