https://project.altservice.com/https://project.altservice.com/favicon.ico?16163160252013-09-16T04:38:45ZALT Project ManagementWebsite Hosting - Feature #196: Adding Redmine to a Centralized Memcache Serverhttps://project.altservice.com/issues/196?journal_id=3162013-09-16T04:38:45ZDaniel Curtistechsupport@altservice.com
<ul></ul><p>After deploying the above implementation, my instance of redmine broke. I could not find a proper guide to connecting redmine to a memcache server for session management. I did find an implementation for the foreman ruby application at <a class="external" href="http://projects.theforeman.org/projects/1/wiki/Set_up_memcached">http://projects.theforeman.org/projects/1/wiki/Set_up_memcached</a><br />I have adapted the implementation to redmine, with a few minor adjustments.</p>
<a name="Set-up-memcached"></a>
<h2 >Set up memcached<a href="#Set-up-memcached" class="wiki-anchor">¶</a></h2>
<p>Instead of using memcache-client, we are going to use Dalli, a ruby gem that allows Rails to use your memcached store.</p>
<a name="Include-this-in-your-Gemfile"></a>
<h3 >Include this in your Gemfile<a href="#Include-this-in-your-Gemfile" class="wiki-anchor">¶</a></h3>
<blockquote>
<p>gem 'dalli'</p>
</blockquote>
<p>Then run:<br /><pre>
bundle install
</pre></p>
<p>Open your environment config file, it is in <code>config/environments/*.rb</code>. Let's assume you will want to set memcached as your production cache store, such as <code>config/environments/production.rb</code></p>
<p>Add the following line in the <code>RedmineApp::Application.configure</code> block</p>
<blockquote>
<p>config.cache_store = :dalli_store</p>
</blockquote>
<p>Reboot your server (nginx, passenger, mongrel, thin..)</p>
<a name="Additional-options"></a>
<h2 >Additional options<a href="#Additional-options" class="wiki-anchor">¶</a></h2>
<p>If you have your own separate cache servers, just add it after the command like this:</p>
<blockquote>
<p>config.cache_store = :dalli_store, 'cache1.myserver.com', 'cache2.myserver.com'</p>
</blockquote>
<a name="Use-memcached-to-manage-sessions"></a>
<h2 >Use memcached to manage sessions<a href="#Use-memcached-to-manage-sessions" class="wiki-anchor">¶</a></h2>
<p>Just add something like this to your <code>config/environment.rb</code>:</p>
<blockquote>
<p>require 'action_dispatch/middleware/session/dalli_store'<br />Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 20.minutes</p>
</blockquote> Website Hosting - Feature #196: Adding Redmine to a Centralized Memcache Serverhttps://project.altservice.com/issues/196?journal_id=6092014-04-25T23:31:54ZDaniel Curtistechsupport@altservice.com
<ul></ul><p>I found a better way to cache sessions, still using the <strong>dalli</strong> gem however:<br /><pre>
vi /path/to/redmine/config/environments/production.rb
</pre></p>
<p>Then add the following right after <strong>RedmineApp::Application.configure do</strong>:<br /><pre>
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.action_controller.perform_caching = true
# config.cache_store = :dalli_store
require 'action_dispatch/middleware/session/dalli_store'
Rails.application.config.session_store :dalli_store \
, :memcache_server => ['localhost', '127.0.0.1'] \
, :namespace => 'sessions' \
, :key => '_foundation_session' \
, :expire_after => 20.minutes \
, :compress => true \
, :compressor => Dalli::GzipCompressor \
, :keepalive => true \
, :expires_in => 5.minutes
#config.cache_store = :dalli_store, 'localhost',
#{ :namespace => "redmine_pro", :expires_in => 3600, :compress => true }
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
</pre></p> Website Hosting - Feature #196: Adding Redmine to a Centralized Memcache Serverhttps://project.altservice.com/issues/196?journal_id=21582015-05-09T19:06:14ZDaniel Curtistechsupport@altservice.com
<ul><li><strong>Project</strong> changed from <i>24</i> to <i>Website Hosting</i></li></ul>