Item10462: add support to run a command on a specific virtual host
Priority: Enhancement
Current State: Closed
Released In: n/a
Target Release: n/a
While it is possible to run a command on all vhosts using
VirtualHost->run_on_each()
, there's also a requirement to run a command on one specific host:
# StaticMethod
sub run_on {
my ($class, $hostname, $code) = @_;
my %hostnames =
map { $_ => 1 }
grep { $class->exists($_) && $_ ne '_template' }
map { basename $_} glob($Foswiki::cfg{VirtualHostingContrib}{VirtualHostsDir} . '/*');
die "ERROR: unknown virtual host $hostname\n" unless defined $hostnames{$hostname};
my $virtual_host = $class->find($hostname);
$virtual_host->run($code);
}
--
MichaelDaum - 09 Mar 2011
I am ok with this, but how will users trigger such command, i.e. what did you think in terms of user interface for this feature?
--
AntonioTerceiro - 11 Mar 2011
That's required by cronjobs and scripts that have to operate on one specific vhost. I am currently in the process of making
SolrPlugin aware of virtual hosting. For instance there's an iwatch daemon that watches the data directories of the vhosts and triggers an indexing job for that specific instance.... that's where I need
run_on()
. There are now
virtualhots-(solrindex|solrjob|solrsearch|solrdelete)
scripts that are able to either run on all vhosts or a specific one. To update the index of domainA you'd call
virtualhosts-solrindex host=domainA mode=delta
.
--
MichaelDaum - 11 Mar 2011
That looks nice, please go ahead. It would be nice if you provide unit tests for this new functionality to avoid having it broken in the future.
--
AntonioTerceiro - 11 Mar 2011