Diasporas components explained: Difference between revisions

From diaspora* project wiki
No edit summary
Line 1: Line 1:
== Run Diasporas Components directly ==
== Rails ==


If you fear <tt>./script/server</tt> for some strange reason ;)
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.


=== A note about production mode ===
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>.


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!
=== Database ===


=== 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 prefix all commands with <tt>DB=postgres</tt>.


Be sure to prepend every command with <tt>DB=…</tt> if you did at installation time.
=== Application server ===


=== Ensure Redis is running ===
This server generates the dynamic content. It's bad at hosting static content though.


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.
<syntaxhighlight lang="bash">
bundle exec 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 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>
<syntaxhighlgight 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>
 
This is also essential unless you turn on <tt>environment.single_process_mode</tt> in <tt>config/diaspora.yml</tt> which is absolutely not recommended for production environments. 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]]

Revision as of 15:32, 24 June 2013

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 prefix all commands with DB=postgres.

Application server

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

bundle exec 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 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:

<syntaxhighlgight lang="bash"> bundle exec sidekiq </syntaxhighlight>

This is also essential unless you turn on environment.single_process_mode in config/diaspora.yml which is absolutely not recommended for production environments. 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.