YunoHost-Apps / mastodon_ynh

Free, open-source social network for YunoHost
https://joinmastodon.org/
GNU Affero General Public License v3.0
84 stars 36 forks source link

tootctl issues: could not connect to server: Connection refused (PG::ConnectionBad) #216

Closed Mo-Et closed 4 years ago

Mo-Et commented 4 years ago

Hi all, First, thank you so much for this app! I've been having a great time using it. I'm now facing an issue: media_attachments have filled up my available space, and want to remove some using tootctl, as I think is the right way. However, tootctl won't run and I get the following error:

root@domain:/var/www/mastodon/live# RAILS_ENV=production bin/tootctl help

Traceback (most recent call last): 120: from bin/tootctl:4:in '<main>' 119: from /var/www/mastodon/live/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in 'require_relative' [...] 1: from /var/www/mastodon/live/vendor/bundle/ruby/2.6.0/gems/pg-1.2.2/lib/pg.rb:58:in 'new' /var/www/mastodon/live/vendor/bundle/ruby/2.6.0/gems/pg-1.2.2/lib/pg.rb:58:in 'initialize': could not connect to server: Connection refused (PG::ConnectionBad) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

(I skipped a bunch of lines, let me know if they would be useful) My most urgent goal is to free space on the server, as it is for now completely filled and nothings works properly. Could I just remove the media with an rm or will it mess the database? Maybe the filled memory is what's preventing tootctl from working, but if not, have you any idea how I could fix it? I will need to be able to regularly remove media attachments to prevent it from happening again.

Thanks! Cheers.


Salut à tous, Tout d'abord, merci beaucoup pour cette app ! C'est très agréable à utiliser. J'ai un problème depuis ajourd'hui: media_attachments a rempli mon espace disponible, et je voudrais vider le dossier avec tootctl, je crois que c'est la bonne manière de faire. Mais, tootctl ne s'exécute pas et j'obtiens l'erreur reportée ci-dessus (J'ai efacé beaucoup de lignes, dites moi si elles peuvent être utiles) Mon but le plus urgent est de libérer de l'espace sur le serveur, puisqu'il est complètement plein et que rien ne marche bien pour le moment. Est-ce que je peux supprimer ces fichiers avec un rm ou est-ce que cela va corrompre ma base de données ? Peut être que la mémoire pleine est ce qui cause des erreurs pour tootctl, mais si ce n'est pas le cas, avez-vous une idée pour résoudre le problème ? Je vais avoir besoin de supprimer les medias régulirement pour éviter que la situation ne se reproduise.

Merci! Cheers.

Mo-Et commented 4 years ago

Hi all, Ok I solved it, it was indeed the full disk space that was the issue. Here's how I did it:

Everything went back to normal. I reckon that the issue was that Mastodon creates temporary database indices before removing old media, and could not in my case due to the full disk...

I have now set up a cron job to remove media daily (inspired by this post). Here's, in the case of Yunohost install, the script I wrote (as root user, in /root in my case)

#!/bin/bash

export PATH=/opt/rbenv/shims:$PATH
export RAILS_ENV=production

/var/www/mastodon/live/bin/tootctl media remove --days=1
/var/www/mastodon/live/bin/tootctl statuses remove --days=15

then chmod +x mastodon_media_control, and with crontab -e add

0 5 * * * /root/mastodon_media_control

to delete media and old statuses on a daily basis (the number of days depends of the space you are willing to allocate to Mastodon).

Removed media are still accessible if you go back to an old post, you will just download it again. Old statuses, as I understood, are not (I may be wrong here).

IMO this cron job could be part of the README.md of mastodon_ynh, as unexperienced users as myself could be facing full disk issues when running Mastodon (I had no idea how media were handled, and frankly did not bother with the question until I faced those problems).

Again, thank you so much for the accessible app, you are doing a great job! :)