我该如何在生产服务器上运行Yard服务器?
也许可以使用一些任务?
通过capistrano加载,使用passenger和nginx,Jenkins(Hudson)。
$ cd <railsapp>
$ ls
Gemfile
app/
..
public/
doc/ <- Folder that contains the html files generated by yard
$ cd public/
$ ln -s ../doc/ docs
#!/bin/sh
#or you process here
PROCESS='ruby */yard server'
PID=`pidof $PROCESS`
start() {
yard server &
}
stop() {
if [ "$PID" ];then
kill -KILL $PID
echo 'yard is stopped'
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo Usage: $0 [start|stop|restart]
;;
esac
yard doc && ./yard.sh restart
。我使用nginx和passenger来提供这个小型Web应用程序:
# ~/Documentation/config.ru
require 'rubygems'
require 'yard'
libraries = {}
gems = Gem.source_index.find_name('').each do |spec|
libraries[spec.name] ||= []
libraries[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)
end
run YARD::Server::RackAdapter.new libraries
Nginx虚拟主机:
# /opt/nginx/config/sites-enabled/gems.doc
server {
listen 80;
server_name gems.doc;
root /Users/your-user/Documentation/yard/public;
rails_env development;
passenger_enabled on;
}