Scott Seago
2009-Jan-21 19:24 UTC
[Ovirt-devel] [PATCH] Update search index every half hour.
Sets up a cron job to update the search index every half hour. With this in place it will be at most 30 minutes after new/updated content is generated before it will show up in search results. Signed-off-by: Scott Seago <sseago at redhat.com> --- conf/ovirt-server.crontab | 2 ++ ovirt-server.spec.in | 3 +++ scripts/ovirt-reindex-search | 4 +++- scripts/ovirt-update-search | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 conf/ovirt-server.crontab diff --git a/conf/ovirt-server.crontab b/conf/ovirt-server.crontab new file mode 100644 index 0000000..0f643ba --- /dev/null +++ b/conf/ovirt-server.crontab @@ -0,0 +1,2 @@ +MAILTO=root +0,30 * * * * root /usr/sbin/ovirt-update-search diff --git a/ovirt-server.spec.in b/ovirt-server.spec.in index 79a5adf..63e1b2a 100644 --- a/ovirt-server.spec.in +++ b/ovirt-server.spec.in @@ -65,6 +65,7 @@ mkdir %{buildroot} %{__install} -d -m0755 %{buildroot}%{_sysconfdir}/httpd/conf.d %{__install} -d -m0755 %{buildroot}%{_sysconfdir}/%{name} %{__install} -d -m0755 %{buildroot}%{_sysconfdir}/%{name}/db +%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/cron.d %{__install} -d -m0755 %{buildroot}%{_localstatedir}/lib/%{name} %{__install} -d -m0755 %{buildroot}%{_localstatedir}/log/%{name} %{__install} -d -m0755 %{buildroot}%{_localstatedir}/run/%{name} @@ -75,6 +76,7 @@ touch %{buildroot}%{_localstatedir}/log/%{name}/rails.log touch %{buildroot}%{_localstatedir}/log/%{name}/taskomatic.log touch %{buildroot}%{_localstatedir}/log/%{name}/db-omatic.log %{__install} -p -m0644 %{pbuild}/conf/%{name}.conf %{buildroot}%{_sysconfdir}/httpd/conf.d +%{__install} -p -m0644 %{pbuild}/conf/%{name}.crontab %{buildroot}%{_sysconfdir}/cron.d/%{name} %{__install} -Dp -m0755 %{pbuild}/conf/ovirt-host-browser %{buildroot}%{_initrddir} %{__install} -Dp -m0755 %{pbuild}/conf/ovirt-db-omatic %{buildroot}%{_initrddir} @@ -177,6 +179,7 @@ fi %{_initrddir}/ovirt-host-collect %{_initrddir}/ovirt-mongrel-rails %{_initrddir}/ovirt-taskomatic +%{_sysconfdir}/cron.d/%{name} %config(noreplace) %{_sysconfdir}/sysconfig/ovirt-mongrel-rails %config(noreplace) %{_sysconfdir}/sysconfig/ovirt-rails %config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf diff --git a/scripts/ovirt-reindex-search b/scripts/ovirt-reindex-search index c693300..cf4e38e 100755 --- a/scripts/ovirt-reindex-search +++ b/scripts/ovirt-reindex-search @@ -1,4 +1,6 @@ #!/bin/bash +[ -r /etc/sysconfig/ovirt-rails ] && . /etc/sysconfig/ovirt-rails +RAILS_ENV="${RAILS_ENV:-production}" RAKEFILE=/usr/share/ovirt-server/Rakefile MODELS="Host Vm IscsiStoragePool NfsStoragePool HardwarePool VmResourcePool" -rake -f $RAKEFILE xapian:rebuild_index models="$MODELS" +RAILS_ENV=$RAILS_ENV rake -f $RAKEFILE xapian:rebuild_index models="$MODELS" diff --git a/scripts/ovirt-update-search b/scripts/ovirt-update-search index ba4f6f2..2b2c107 100755 --- a/scripts/ovirt-update-search +++ b/scripts/ovirt-update-search @@ -1,4 +1,6 @@ #!/bin/bash +[ -r /etc/sysconfig/ovirt-rails ] && . /etc/sysconfig/ovirt-rails +RAILS_ENV="${RAILS_ENV:-production}" RAKEFILE=/usr/share/ovirt-server/Rakefile MODELS="Host Vm IscsiStoragePool NfsStoragePool HardwarePool VmResourcePool" -rake -f $RAKEFILE xapian:update_index models="$MODELS" +RAILS_ENV=$RAILS_ENV rake -f $RAKEFILE xapian:update_index models="$MODELS" -- 1.6.0.6
Daniel P. Berrange
2009-Jan-21 20:55 UTC
[Ovirt-devel] [PATCH] Update search index every half hour.
On Wed, Jan 21, 2009 at 07:24:27PM +0000, Scott Seago wrote:> Sets up a cron job to update the search index every half hour. > With this in place it will be at most 30 minutes after new/ > updated content is generated before it will show up in search results.30 minutes seems like quite a long time. Is there much CPU overhead from updating the search index ? If not I think it'd be nicer to do it every 5 minutes or more frequently still. Shame it can't be done "on demand" really - eg triggered when an indexable table is updated - albeit it with a small delay, so if multiple updates arrive in a short time it can coalleasce into one index update. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|