Diasporas components explained: Difference between revisions

From diaspora* project wiki
(Created page with "== Run Diasporas Components directly == If you fear <tt>./script/server</tt> for some strange reason ;) === A note about production mode === If you want to use production m...")
 
(Remove obsolete sentence about single_process_mode)
 
(14 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Run Diasporas Components directly ==
{{Out of date}}{{Note|1=I think this page is '''still up to date'''. I set the ''out of date'' template anyway, to add the page to the review queue.<br />
I'm not sure if we still need this page. If the content of this page is sufficiently described elsewhere (in the [[installation]] guides or [[FAQ for pod maintainers]] or [[FAQ for developers]]..) it can be deleted without replacement.<br />
If this page is to keep, to me it looks like this page could perhaps be merged with [[An introduction to the Diaspora source]] (although they describe different parts of diaspora.. hm.). At the moment, both pages look somehow lost. --[[User:Waithamai|waithamai]] <sup>[[User talk:Waithamai|talk]]</sup> 07:12, 17 August 2017 (UTC)}}


If you fear <tt>./script/server</tt> for some strange reason ;)
== Rails ==


=== A note about production mode ===
Diaspora is a Ruby on Rails application. Rails knows so called environments, or running modes. The main ones are <tt>production</tt> and <tt>development</tt>. The main difference is whether the code is reloaded with each request, this is very slow but also very handy for development. We also have slightly different default configuration values.


If you want to use production mode prepend every command here with <tt>RAILS_ENV=production</tt>, the server section <tt>config/diaspora.yml</tt> is not respected with this way!
The default is <tt>development</tt>, for production setups you want to run in, well, <tt>production</tt> mode. To do that prefix all commands with <tt>RAILS_ENV=production</tt>.


=== Database ===
== Database ==


Be sure to prepend every command with <tt>DB=…</tt> if you did at installation time.
Either MySQL/MariaDB or PostgreSQL. Used to store all persistent data except uploaded images, like users, profiles, posts, likes and comments.


=== Ensure Redis is running ===
The default is MySQL, if you want to use PostgreSQL make sure to <tt>export DB=postgres</tt> in the diaspora user's <tt>.bashrc</tt> (or whatever shell environment file you use).


If you compiled Redis from source run <tt>redis-server</tt> to start Redis on the default port 6379. It uses a config file, normally <tt>/etc/redis.conf</tt> or <tt>/etc/redis/redis.conf</tt> defining ports and other stuff. If you installed via a package manager there's most likely an init script you want to use.
== Application server ==
 
This server generates the dynamic content. It's bad at hosting static content though.
 
<syntaxhighlight lang="bash">
bundle exec unicorn_rails -c config/unicorn.rb -p 3000
</syntaxhighlight>  


=== Run the app server ===
from Diasporas base directory starts the default application server we recommend. It will run on port 3000 by default. If you want it to be available on port 80, either run it on port 80 directly (very unwise, you shouldn't run Diaspora as root) or use a webserver of your choice to proxy port 443 and/or 80 at your domain name to Unicorn at port 3000. You can also forward the requests over a UNIX socket. This is absolutely needed unless you want to use a different application server, like Passenger for example.


Run <tt>bundle exec bundle exec unicorn_rails -c config/unicorn.rb -p 3000</tt> from the root Diaspora directory. This will start the Appserver. It will run on port 3000 by default. If you want it to be available on port 80, either run it on port 80 directly (unwise, you shouldn't run Diaspora as root) or use the Webserver of choice to proxy port 443 and/or 80 at your domain name to Unicorn at port 3000 or over a socket. This is absolutely needed unless you want to use a different Appserver like Passenger for example.
== Sidekiq ==


=== Run the Sidekiq worker ===
Sidekiq is a job processing system. We use it to take all time intensive task outside the request cycle. This includes for example sending posts to other pods, fetching remote profiles or sending mail.


To start the Sidekiq worker run the following command:
To start the Sidekiq worker run the following command:


<pre>bundle exec sidekiq</pre>
<syntaxhighlight lang="bash">
This is also essential unless you turn on single_process_mode in <tt>config/diaspora.yml</tt> which is absolutely not recommended for production environments. Sidekiq is used for time intensive jobs like sending mail, sending and receiving messages from other pods etc. Add <tt>-d -P tmp/sidekiq.pid</tt> to daemonize it. You can stop it with <tt>bundle exec sidekiqctl stop tmp/sidekiq.pid</tt>.
bundle exec sidekiq
</syntaxhighlight>
 
Add <tt>-d -P tmp/sidekiq.pid</tt> to daemonize it. You can stop it with <tt>bundle exec sidekiqctl stop tmp/sidekiq.pid</tt>.
 
 
== Redis ==
 
Redis is a key-value store. It's an in memory database used to communicate between the application server and Sidekiq.
 
If you compiled Redis from source run <tt>redis-server</tt> to start Redis on the default port 6379. It uses a config file, normally <tt>/etc/redis.conf</tt> or <tt>/etc/redis/redis.conf</tt> defining ports and other stuff. If you installed via a package manager there's most likely an init script you want to use.


[[Category:Github transfer done]]
[[Category:Github transfer done]]
[[Category:Developers]]
[[Category:Installation]]
[[Category:Podmin]]

Latest revision as of 23:18, 9 June 2024

Out of dateOut of date:This page's accuracy may be compromised due to out-of-date information. Please help improve the page by updating it. There may be additional information on the talk page.
NoteNote:I think this page is still up to date. I set the out of date template anyway, to add the page to the review queue.

I'm not sure if we still need this page. If the content of this page is sufficiently described elsewhere (in the installation guides or FAQ for pod maintainers or FAQ for developers..) it can be deleted without replacement.

If this page is to keep, to me it looks like this page could perhaps be merged with An introduction to the Diaspora source (although they describe different parts of diaspora.. hm.). At the moment, both pages look somehow lost. --waithamai talk 07:12, 17 August 2017 (UTC)

Rails

Diaspora is a Ruby on Rails application. Rails knows so called environments, or running modes. The main ones are production and development. The main difference is whether the code is reloaded with each request, this is very slow but also very handy for development. We also have slightly different default configuration values.

The default is development, for production setups you want to run in, well, production mode. To do that prefix all commands with RAILS_ENV=production.

Database

Either MySQL/MariaDB or PostgreSQL. Used to store all persistent data except uploaded images, like users, profiles, posts, likes and comments.

The default is MySQL, if you want to use PostgreSQL make sure to export DB=postgres in the diaspora user's .bashrc (or whatever shell environment file you use).

Application server

This server generates the dynamic content. It's bad at hosting static content though.

bundle exec unicorn_rails -c config/unicorn.rb -p 3000

from Diasporas base directory starts the default application server we recommend. It will run on port 3000 by default. If you want it to be available on port 80, either run it on port 80 directly (very unwise, you shouldn't run Diaspora as root) or use a webserver of your choice to proxy port 443 and/or 80 at your domain name to Unicorn at port 3000. You can also forward the requests over a UNIX socket. This is absolutely needed unless you want to use a different application server, like Passenger for example.

Sidekiq

Sidekiq is a job processing system. We use it to take all time intensive task outside the request cycle. This includes for example sending posts to other pods, fetching remote profiles or sending mail.

To start the Sidekiq worker run the following command:

bundle exec sidekiq

Add -d -P tmp/sidekiq.pid to daemonize it. You can stop it with bundle exec sidekiqctl stop tmp/sidekiq.pid.


Redis

Redis is a key-value store. It's an in memory database used to communicate between the application server and Sidekiq.

If you compiled Redis from source run redis-server to start Redis on the default port 6379. It uses a config file, normally /etc/redis.conf or /etc/redis/redis.conf defining ports and other stuff. If you installed via a package manager there's most likely an init script you want to use.