From 8be94ade02fcff97a0071c76d7a4f23a6d97dfd6 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Mon, 2 Dec 2019 21:04:01 +0100 Subject: [PATCH] Make the app install and remove --- conf/diaspora.target | 6 ++--- conf/diaspora.tmpfiles.d | 1 + conf/diaspora.yml | 9 ++++--- conf/diaspora_appserver.service | 17 ------------- conf/diaspora_sidekiq.service | 14 ++++++++++ conf/diaspora_web.service | 16 ++++++++++++ conf/nginx.conf | 45 ++++++++++++++++++++------------- 7 files changed, 67 insertions(+), 41 deletions(-) create mode 100644 conf/diaspora.tmpfiles.d delete mode 100644 conf/diaspora_appserver.service create mode 100644 conf/diaspora_sidekiq.service create mode 100644 conf/diaspora_web.service diff --git a/conf/diaspora.target b/conf/diaspora.target index 938aad1..8a4ce7c 100644 --- a/conf/diaspora.target +++ b/conf/diaspora.target @@ -1,7 +1,7 @@ [Unit] -Description=Diaspora social network -Wants=redis.service mysqld.service -After=redis.service mysqld.service +Description=Diaspora social network (instance {{ app}}) +Wants=redis.service postgresql.service +After=redis.service postgresql.service StopWhenUnneeded=true [Install] diff --git a/conf/diaspora.tmpfiles.d b/conf/diaspora.tmpfiles.d new file mode 100644 index 0000000..ffe6df2 --- /dev/null +++ b/conf/diaspora.tmpfiles.d @@ -0,0 +1 @@ +d /run/{{ app }} 0755 {{ app }} {{ app }} - - diff --git a/conf/diaspora.yml b/conf/diaspora.yml index 89e8ab4..7c417ca 100644 --- a/conf/diaspora.yml +++ b/conf/diaspora.yml @@ -36,7 +36,7 @@ configuration: ## Section ## However changing http to https is okay and has no consequences. ## If you do change the URL, you will have to start again as the URL ## will be hardcoded into the database. - url: "FULLURLTOCHANGE" + url: "https://{{ domain }}{{ path_url }}" ## Set the bundle of certificate authorities (CA) certificates. ## This is specific to your operating system. @@ -175,15 +175,16 @@ configuration: ## Section ## Where the appserver should listen to (default=unix:tmp/diaspora.sock) #listen: 'unix:tmp/diaspora.sock' #listen: 'unix:/run/diaspora/diaspora.sock' - listen: '127.0.0.1:3986' + #listen: '127.0.0.1:3000' + listen: unix:/run/{{ app }}/diaspora.sock ## Set the path for the PID file of the unicorn master process (default=tmp/pids/web.pid) - #pid: 'tmp/pids/web.pid' + pid: '/run/{{ app }}/diaspora.pid' ## Rails environment (default='development'). ## The environment in which the server should be started by default. ## Change this to 'production' if you wish to run a production environment. - #rails_environment: 'development' + rails_environment: 'production' ## Write unicorn stderr and stdout log. #stderr_log: '/usr/local/app/diaspora/log/unicorn-stderr.log' diff --git a/conf/diaspora_appserver.service b/conf/diaspora_appserver.service deleted file mode 100644 index 194b76e..0000000 --- a/conf/diaspora_appserver.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=Diaspora social network (application server) -PartOf=diaspora.target -StopWhenUnneeded=true - -[Service] -User=diaspora -WorkingDirectory=/var/www/diaspora -Environment=RAILS_ENV=production -ExecStart=/var/www/diaspora/.rvm/scripts/extras/chruby.sh 2.2 -- bin/bundle exec puma -b unix:///var/run/diaspora/diaspora.sock -e $RAILS_ENV -Restart=always -CPUAccounting=true -MemoryAccounting=true -BlockIOAccounting=true - -[Install] -WantedBy=diaspora.target diff --git a/conf/diaspora_sidekiq.service b/conf/diaspora_sidekiq.service new file mode 100644 index 0000000..7bee105 --- /dev/null +++ b/conf/diaspora_sidekiq.service @@ -0,0 +1,14 @@ +[Unit] +Description=Diaspora social network (sidekiq - instance {{ app }}) +PartOf={{ app }}.target +StopWhenUnneeded=true + +[Service] +User={{ app }} +Environment=RAILS_ENV=production +WorkingDirectory={{ final_path }}/diaspora +ExecStart=/bin/bash -lc "bin/bundle exec sidekiq" +Restart=always + +[Install] +WantedBy={{ app }}.target diff --git a/conf/diaspora_web.service b/conf/diaspora_web.service new file mode 100644 index 0000000..837fad7 --- /dev/null +++ b/conf/diaspora_web.service @@ -0,0 +1,16 @@ +[Unit] +Description=Diaspora social network (unicorn - instance {{ app }}) +PartOf={{ app }}.target +StopWhenUnneeded=true + +[Service] +User={{ app }} +Environment=RAILS_ENV=production +WorkingDirectory={{ final_path }}/diaspora +PIDFile=/run/{{ app }}/diaspora.pid +ExecStart=/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production" +ExecReload=/bin/kill -USR2 $MAINPID +Restart=always + +[Install] +WantedBy={{ app }}.target diff --git a/conf/nginx.conf b/conf/nginx.conf index 54bb4f3..8faded4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,22 +1,33 @@ # Proxy if requested file not found -try_files $uri @diaspora; -root ROOTOCHANGE/public; +location __PATH__ { -location @diaspora { - # Configure maximum picture size - # Note that Diaspora has a client side check set at 4M - client_max_body_size 5M; - client_body_buffer_size 256K; - - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto https; - proxy_set_header Host $http_host; - proxy_redirect off; - - proxy_pass http://diaspora_server; + root __FINALPATH__/diaspora/public; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; +# Configure maximum picture size +# Note that Diaspora has a client side check set at 4M + client_max_body_size 5M; + client_body_buffer_size 256K; + +# Proxy if requested file not found + try_files $uri @diaspora; + + location __PATH__/assets/ { + expires max; + add_header Cache-Control public; + } + +# Include SSOWAT user panel. +# TODO check that + include conf.d/yunohost_panel.conf.inc; } +location @diaspora { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Host $http_host; + proxy_redirect off; + + proxy_pass http://unix:/run/__NAME__/diaspora.sock; + +}