#705026: Allow creation of example.com/foo and example.com/bar type of sites (Part I) introduced subdirectory support. This is unlikely to work in multi-server setups. First step is to test, and confirm that it doesn't work. I suspect that #2020075: Refactor subdirs to use proper Config class(es) may just fix this, but maybe not. Either way, we'll need to confirm that we're sync'ing over the proper config files, putting the subdirs.d in place, etc.

Comments

lieb’s picture

I have tested, both with Mig5's original module, and with 6.x-2.0-beta1. My testing has been done with a server pack, with 2 remote servers. Here is what I can tell you.

The problem is that the subdirs.d (was stub.d) directory get's created under server_master and not on the server(s) actually hosing the site. I have made it work by manually copying this directory to the remote servers' apache directory, but then it breaks whenever the platform is verified.

In 2.0-beta1 the code that creates the subdirs.d directory is on line 152 of provision/subdirs/subdirs.drush.inc.

$subdirs_path = $context->server->http_app_path . '/subdirs.d';
however this is not the problem. Looking at the alias for the site in question, I see

'server' => '@server_master',
which is what the code is getting. However to get the right servers you'd have to drill down deeper.

The alias for the platform has

'server' => '@server_master', 
'web_server' => '@server_pack1', 

And the alias for the web_server has

'slave_web_servers' =>
  array (
    0 => '@server_aegir1',
    1 => '@server_aegir2',
  ),

So you would have to drill down to get the slave_web_servers to get the correct servers to build the path for the subdirs.d folder.

If you think my thinking is correct here I could try and write a patch to do this. I'm not sure however if this logic would hold up for other multi-server environments without setting those up and testing.

lieb’s picture

Status: Active » Needs review
cweagans’s picture

This sounds like a good approach. I have tested it with the more simple setup of having just one remote web server (not using cluster or pack module), and I can confirm that remote subdirectory sites don't work in that setup either.

anarcat’s picture

So the problem here is related to #2020075: Refactor subdirs to use proper Config class(es): the current subdir code doesn't properly "sync()" files to the remote servers. Usually, in other configuration files, there's a special sync() function that gets called at some point to make sure the files get sent to the remote server.

This may be only what is missing here.

lieb’s picture

Status: Needs review » Needs work

So after beating on this for a while I have now determined that, at least with 2.0-RC2, sub-directory sites even in a single server environment do not work. You can get to the front page, but any path under that, i.e. /user, brings up a 404. So, unless I'm really missing something we are back to square one on this.
I tested on a couple of different servers, but most recently with a new clean install of 2.0-RC2.

anarcat’s picture

this issue is specifically about multi-server, how about we open a separate issue about that 404?

anarcat’s picture

i opened this issue, which i can reproduce, about the 404: #2097689: clean_urls don't work well with subdirectory.

Yet the problem with syncing files here remains - the subdir code doesn't properly sync() files around like the other modules do. It also doesn't properly use the provision_file() primitives, although that is less of a problem.

anarcat’s picture

Turns out we don't need #2020075: Refactor subdirs to use proper Config class(es) - just need to sync the file names already.

I got this patch that syncs the files, but it puts them in server_master on the remote server, which is not right...

diff --git a/subdirs/subdirs.drush.inc b/subdirs/subdirs.drush.inc
index 3324ca1..c4c8fa2 100644
--- a/subdirs/subdirs.drush.inc
+++ b/subdirs/subdirs.drush.inc
@@ -152,16 +152,19 @@ function _subdirs_create_site_location($alias) {
   $subdirs_path = $context->server->http_app_path . '/subdirs.d';
   if (!is_dir($subdirs_path)) {
     mkdir($subdirs_path);
+    d()->service('http')->sync($subdirs_path);
   }
   $includes_path = $subdirs_path . '/' . $alias_parts[0];
   if (!is_dir($includes_path)) {
     mkdir($includes_path);
+    d()->service('http')->sync($includes_path);
   }
 
   $location_path = $includes_path . '/' . $alias_parts[1] . '.conf';
 
   if (fwrite(fopen($location_path, 'w'), $output)) {
     drush_log('Created site location config file for subdirectory ' . $alias . ' at ' . $location_path, 'success');
+    d()->service('http')->sync($location_path);
   }
   else {
     drush_log('Error encountered attempting to create site location config file for subdirectory ' . $alias, 'error');
@@ -189,6 +192,7 @@ function _subdirs_create_domain_vhost($alias) {
 
   if (fwrite(fopen($domain_vhost_path, 'w'), $output)) {
     drush_log('Created domain vhost for subdirectory ' . $alias . ' at ' . $domain_vhost_path, 'success');
+    d()->service('http')->sync($domain_vhost_path);
   }
   else {
     drush_log('Error encountered attempting to create domain vhost for subdirectory ' . $alias, 'error');
@@ -230,6 +234,7 @@ function _subdirs_create_disabled_site_location($alias) {
 
   if (fwrite(fopen($location_path, 'w'), $output)) {
     drush_log('Created disabled site location config file for subdirectory ' . $alias . ' at ' . $location_path, 'success');
+    d()->service('http')->sync($location_path);
   }
   else {
     drush_log('Error encountered attempting to create disabled site location config file for subdirectory ' . $alias, 'error');
@@ -250,6 +255,7 @@ function _subdirs_delete_site_location($alias) {
 
   if (unlink($location_path)) {
     drush_log('Deleted site location config file for subdirectory ' . $alias, 'success');
+    d()->service('http')->sync($location_path);
   }
   else {
     drush_log('Error encountered attempting to delete site location config file for subdirectory ' . $alias, 'error');
@@ -268,6 +274,7 @@ function _subdirs_delete_domain_vhost($alias) {
 
   if (unlink($domain_vhost_path)) {
     drush_log('Deleted domain vhost for subdirectory ' . $alias, 'success');
+    d()->service('http')->sync($domain_vhost_path);
   }
   else {
     drush_log('Error encountered attempting to delete domain vhost for subdirectory ' . $alias, 'error');

So it doesn't actually work just yet.

anarcat’s picture

Status: Needs work » Fixed

i think this works in the dev-subdir-multiserver branch.

ergonlogic’s picture

Status: Fixed » Needs work

From my testing, the symlink on Drupal 6 platforms isn't being created. But it's otherwise working very nicely.

ergonlogic’s picture

Status: Needs work » Fixed

Sorry, my testing was only local.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

cweagans’s picture

anarcat, was this merged into 6.x-2.x? Will it be included in rc5?

csalexyiu’s picture

Issue summary: View changes

Is it workable on Aegir3.5?