Register now and start sharing your code snippets.
-->

How to make Rails plugins reloadable

Ruby posted 16 days ago by christian

I found this snippet on the Railshacks blog:

   1  # Array of plugins that you want to be reloaded on each request
   2  reloadable_plugins = ["has_markup"]
   3  
   4  # Remove the plugins from the load_once_paths variable
   5  reloadable_plugins.each do |plugin_name|
   6    reloadable_path = RAILS_ROOT + "/vendor/plugins/#{plugin_name}/lib"
   7    Dependencies.load_once_paths.delete(reloadable_path)
   8  end

Tagged rails, reload, reloadable

Change nginx configuration on the fly

Shell Script (Bash) posted about 1 year ago by christian

First make your changes to nginx.conf.

Then run the following command to test the new configuration:

   1  # nginx -t -c /etc/nginx/nginx.conf 
   2  2007/10/18 20:55:07 [info] 3125#0: the configuration file /etc/nginx/nginx.conf syntax is ok
   3  2007/10/18 20:55:07 [info] 3125#0: the configuration file /etc/nginx/nginx.conf was tested successfully

Next, look for the process id of the master nginx process:

   1  # ps -ef|grep nginx
   2  root      1911     1  0 18:00 ?        00:00:00 nginx: master process /usr/sbin/nginx
   3  www-data  1912  1911  0 18:00 ?        00:00:00 nginx: worker process

Lastly, tell nginx to reload the configuration and restart the worker processes:

   1  # kill -HUP 1911

Tagged nginx, reload, configuration