From 7c0a9121c96b3ae693dc139662caf5edf6fc6abd Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 28 Jan 2020 17:38:23 +0100 Subject: [PATCH 1/3] Fix Ansible installation, add uninstall playbook --- ansible/lemmy.yml | 15 +++++---- ansible/templates/docker-compose.yml | 35 ++++++++++++++++++++ ansible/uninstall.yml | 48 ++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 ansible/templates/docker-compose.yml create mode 100644 ansible/uninstall.yml diff --git a/ansible/lemmy.yml b/ansible/lemmy.yml index e9ad4dd..6ec4f91 100644 --- a/ansible/lemmy.yml +++ b/ansible/lemmy.yml @@ -29,12 +29,15 @@ - { path: '/lemmy/' } - { path: '/lemmy/volumes/' } - - name: add all template files - template: src={{item.src}} dest={{item.dest}} - with_items: - - { src: '../docker/prod/docker-compose.yml', dest: '/lemmy/docker-compose.yml' } - - { src: 'templates/config.hjson', dest: '/lemmy/lemmy.hjson' } - - { src: 'templates/nginx.conf', dest: '/etc/nginx/sites-enabled/lemmy.conf' } + - block: + - name: add template files + template: src={{item.src}} dest={{item.dest}} mode={{item.mode}} + with_items: + - { src: 'templates/docker-compose.yml', dest: '/lemmy/docker-compose.yml', mode: '0600' } + - { src: 'templates/nginx.conf', dest: '/etc/nginx/sites-enabled/lemmy.conf', mode: '0644' } + + - name: add config file (only during initial setup) + template: src='templates/config.hjson' dest='/lemmy/lemmy.hjson' mode='0600' force='no' owner='1000' group='1000' vars: postgres_password: "{{ lookup('password', 'passwords/{{ inventory_hostname }}/postgres chars=ascii_letters,digits') }}" jwt_password: "{{ lookup('password', 'passwords/{{ inventory_hostname }}/jwt chars=ascii_letters,digits') }}" diff --git a/ansible/templates/docker-compose.yml b/ansible/templates/docker-compose.yml new file mode 100644 index 0000000..96489c7 --- /dev/null +++ b/ansible/templates/docker-compose.yml @@ -0,0 +1,35 @@ +version: '3.3' + +services: + lemmy: + image: dessalines/lemmy:v0.6.5 + ports: + - "127.0.0.1:8536:8536" + restart: always + volumes: + - ./lemmy.hjson:/config/config.hjson:ro + depends_on: + - lemmy_db + - lemmy_pictshare + + lemmy_db: + image: postgres:12-alpine + environment: + - POSTGRES_USER=lemmy + - POSTGRES_PASSWORD={{ postgres_password }} + - POSTGRES_DB=lemmy + volumes: + - lemmy_db:/var/lib/postgresql/data + restart: always + + lemmy_pictshare: + image: shtripok/pictshare:latest + ports: + - "127.0.0.1:8537:80" + volumes: + - lemmy_pictshare:/usr/share/nginx/html/data + restart: always + +volumes: + lemmy_db: + lemmy_pictshare: diff --git a/ansible/uninstall.yml b/ansible/uninstall.yml new file mode 100644 index 0000000..252c5bd --- /dev/null +++ b/ansible/uninstall.yml @@ -0,0 +1,48 @@ +--- +- hosts: all + + vars_prompt: + + - name: confirm_uninstall + prompt: "Do you really want to uninstall Lemmy? This will delete all data and can not be reverted [yes/no]" + private: no + + - name: delete_certs + prompt: "Delete certificates? Select 'no' if you want to reinstall Lemmy [yes/no]" + private: no + + tasks: + - name: end play if no confirmation was given + debug: + msg: "Uninstall cancelled, doing nothing" + when: not confirm_uninstall|bool + + - meta: end_play + when: not confirm_uninstall|bool + + - name: stop docker-compose + docker_compose: + project_src: /lemmy/ + state: absent + + - name: delete data + file: path={{item.path}} state=absent + with_items: + - { path: '/lemmy/' } + - { path: '/etc/nginx/sites-enabled/lemmy.conf' } + + - name: Remove a volume + docker_volume: name={{item.name}} state=absent + with_items: + - { name: 'lemmy_lemmy_db' } + - { name: 'lemmy_lemmy_pictshare' } + + - name: delete entire ecloud folder + file: path='/mnt/repo-base/' state=absent + when: delete_certs|bool + + - name: remove certbot cronjob + cron: + name=certbot-renew-lemmy + state=absent + From b3e1930d03865d54806ff3047a40f5b8ec7c7d1b Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 28 Jan 2020 16:50:40 +0100 Subject: [PATCH 2/3] Add script to test http api, fix two api calls --- server/query_testing/apache_bench_report.sh | 3 +- server/query_testing/api_benchmark.sh | 34 +++++++++++++++++++ .../query_testing/generate_explain_reports.sh | 3 +- server/src/api/site.rs | 4 +-- ui/src/services/WebSocketService.ts | 4 +-- 5 files changed, 42 insertions(+), 6 deletions(-) create mode 100755 server/query_testing/api_benchmark.sh diff --git a/server/query_testing/apache_bench_report.sh b/server/query_testing/apache_bench_report.sh index c22af73..62b3e86 100755 --- a/server/query_testing/apache_bench_report.sh +++ b/server/query_testing/apache_bench_report.sh @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/bash +set -e declare -a arr=( "https://mastodon.social/" diff --git a/server/query_testing/api_benchmark.sh b/server/query_testing/api_benchmark.sh new file mode 100755 index 0000000..8f8c65f --- /dev/null +++ b/server/query_testing/api_benchmark.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +# By default, this script runs against `http://127.0.0.1:8536`, but you can pass a different Lemmy instance, +# eg `./api_benchmark.sh "https://example.com"`. +DOMAIN=${1:-"http://127.0.0.1:8536"} + +declare -a arr=( +"/api/v1/site" +"/api/v1/categories" +"/api/v1/modlog" +"/api/v1/search?q=test&type_=Posts&sort=Hot" +"/api/v1/community" +"/api/v1/community/list?sort=Hot" +"/api/v1/post/list?sort=Hot&type_=All" +) + +## now loop through the above array +for path in "${arr[@]}" +do + URL="$DOMAIN$path" + printf "\n\n\n" + echo "testing $URL" + curl --show-error --fail --silent "$URL" >/dev/null + ab -c 64 -t 10 "$URL" > out.abtest + grep "Server Hostname:" out.abtest + grep "Document Path:" out.abtest + grep "Requests per second" out.abtest + grep "(mean, across all concurrent requests)" out.abtest + grep "Transfer rate:" out.abtest + echo "---" +done + +rm *.abtest diff --git a/server/query_testing/generate_explain_reports.sh b/server/query_testing/generate_explain_reports.sh index 9ba9103..0dc06f6 100755 --- a/server/query_testing/generate_explain_reports.sh +++ b/server/query_testing/generate_explain_reports.sh @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/bash +set -e # Do the views first diff --git a/server/src/api/site.rs b/server/src/api/site.rs index a5faf34..dfbd5ff 100644 --- a/server/src/api/site.rs +++ b/server/src/api/site.rs @@ -3,7 +3,7 @@ use diesel::PgConnection; use std::str::FromStr; #[derive(Serialize, Deserialize)] -pub struct ListCategories; +pub struct ListCategories {} #[derive(Serialize, Deserialize)] pub struct ListCategoriesResponse { @@ -72,7 +72,7 @@ pub struct EditSite { } #[derive(Serialize, Deserialize)] -pub struct GetSite; +pub struct GetSite {} #[derive(Serialize, Deserialize)] pub struct SiteResponse { diff --git a/ui/src/services/WebSocketService.ts b/ui/src/services/WebSocketService.ts index e72a287..b404219 100644 --- a/ui/src/services/WebSocketService.ts +++ b/ui/src/services/WebSocketService.ts @@ -116,7 +116,7 @@ export class WebSocketService { public listCategories() { this.subject.next( - this.wsSendWrapper(UserOperation.ListCategories, undefined) + this.wsSendWrapper(UserOperation.ListCategories, {}) ); } @@ -255,7 +255,7 @@ export class WebSocketService { } public getSite() { - this.subject.next(this.wsSendWrapper(UserOperation.GetSite, undefined)); + this.subject.next(this.wsSendWrapper(UserOperation.GetSite, {})); } public search(form: SearchForm) { From d81345560f8bde4576d0b4547a4064ab653c41e7 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 31 Jan 2020 22:18:22 +0100 Subject: [PATCH 3/3] updated Dutch translations --- ui/src/translations/nl.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ui/src/translations/nl.ts b/ui/src/translations/nl.ts index 5c8670e..41aa243 100644 --- a/ui/src/translations/nl.ts +++ b/ui/src/translations/nl.ts @@ -211,6 +211,23 @@ export const nl = { open_registration: 'Open registratie', registration_closed: 'Registratie gesloten', enable_nsfw: 'NSFW toestaan', - theme: 'Thema' + theme: 'Thema', + create_private_message: 'Maak een beveiligd bericht', + send_secure_message: 'Verstuur beveiligd bericht', + send_message: 'Verstuur bericht', + message: 'Bericht', + old: 'Oud', + message_sent: 'Bericht verstuurd', + messages: 'Berichten', + matrix_user_id: 'Matrix gebruikers-id', + private_message_disclaimer: 'Waarschuwing: Privé berichten in Lemmy zijn niet beveiligd. Maak een account aan op <1>Riot.im om veilig te communiceren', + donate_to_lemmy: 'Doneer aan Lemmy', + donate: 'Doneer', + from: 'van', + logged_in: 'Ingelogd', + email_already_exists: 'Email bestaat al', + couldnt_create_private_message: 'Kan beveiligd bericht niet maken', + no_private_message_edit_allowed: 'Niet toegestaan om privé berichten te wijzigen', + couldnt_update_private_message: 'Kan beveiligd bericht niet bijwerken' }, };