Topic on Extension talk:Simple Farm

Is there a way to make this use the same database for the wikis?

25
Lieutenant S. Reznov (talkcontribs)
Danwe (talkcontribs)

Using only one DB is not supported currently (as described in the other topic already). When using multiple DBs, after you added your configuration for a new wiki, you have to run maintenance/update.php on that farm member.

Lieutenant S. Reznov (talkcontribs)

Would it be simple to add the ability to use a single database?

I'm making a wiki hosting service and I'm working to make the wiki creation process as fast as possible. If each database on the farm used the same user, that would speed up the process, but it would still be an extra step.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Danwe (talkcontribs)

I think the cost of implementation must be something around two to four working hours. I have not looked at the code for quite a while and I think there was some conceptual problem with why adding this right away was not possible, I think it was because currently the code is taking the data base name as ID for identifying the farm members. If multiple farm members should be allowed to share one database, we had to introduce some other field as the ID to identify farm members.

Around next month, I would have time implementing this if you are interested in hiring me. Of course you could also try implementing this on your own or creating a hack for this. If you submit a patch to gerrit, I would happy to review it.

Lieutenant S. Reznov (talkcontribs)

I'm using multiple databases with a wildcard on the database user for the database prefix. That way the wiki creation process is simplified.

I can also add instructions to the page for how to do this and how it can be beneficial for services that need to be able to create wikis quickly.

I haven't been able to run the update script for a single wiki. What exactly is the command for it? I'm guessing from the instructions that it's

php www/extensions/SimpleFarm/maintenance/maintainFarm.php "php /home/path/to/www/maintenance/update.php" --farmonly=wikihost_mywikiBattlefield

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Danwe (talkcontribs)

Just navigate to your extensions/SimpleFarm/maintenance directory and then execute php maintainFarm.php "php ../../../maintenance/update.php --farmonly=wikihost_mywikiBattlefield.

Or even better, if only doing this for one wiki, you can simply run this from the root of your MW installation:

WIKI=wikihost_mywikiBattlefield php maintenance/update.php

Lieutenant S. Reznov (talkcontribs)
Danwe (talkcontribs)

What exception? Permission denied?

Lieutenant S. Reznov (talkcontribs)

That wasn't it. There was a bunch of stuff. Isn't it not safe to post exceptions? I can take a look again and see generally what it was about.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Danwe (talkcontribs)

It depends on the exception of course. If there is any sensible data in the exception text (like paths you don't want to have revealed, user names, passwords) then you should replace those. But in general there shouldn't be a problem with posting exceptions.

Lieutenant S. Reznov (talkcontribs)

I ran

WIKI=wikihost_mywikiBattlefield php maintenance/update.php

from the root of the MediaWiki installation. I got this:

Turning off Content Handler DB fields for this part of upgrade.
...ipblocks table does not exist, skipping new field patch.
...ipblocks table does not exist, skipping new field patch.
...already have interwiki table
Missing rc_timestamp field of recentchanges table. Should not happen.
Backtrace:
#0 [internal function]: MysqlUpdater->doIndexUpdate()
#1 /home/sasha/web_servers/mywiki.ssu.lt/www/includes/installer/DatabaseUpdater.php(435): call_user_func_array(Array, Array)
#2 /home/sasha/web_servers/mywiki.ssu.lt/www/includes/installer/DatabaseUpdater.php(387): DatabaseUpdater->runUpdates(Array, false)
#3 /home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/update.php(150): DatabaseUpdater->doUpdates(Array)
#4 /home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/doMaintenance.php(110): UpdateMediaWiki->execute()
#5 /home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/update.php(192): require_once('/home/sasha/web...')
#6 {main}

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Danwe (talkcontribs)

If you are setting up your wiki initially, not just doing some update, simply running update.php won't work I guess.

I don't quite remember how I used to set up new wikies. I guess you can either try WIKI=wikihost_mywikiBattlefield php maintenance/install.php or try disabling simple farm and then doing the usual web based setup of the wiki, afterwards re-instating the localsettings with the farm again and then adding the new member to the farm's setup.

Let me know if you have trouble or made it. I really should figure this out again and document it I guess.

Lieutenant S. Reznov (talkcontribs)

Thanks. I'll try that script instead. Having to run through the install setup interface would be a bit too much though, if that's required, since I'm using the extension to run a wiki hosting service; wiki creation should be as simple as possible. Adding a database, copying and pasting a few wiki config settings, and running the install script would be enough. I can also add whatever I do to the documentation. I think there's a few other things I need to add like removing the wiki name and database name settings from LocalSettings.php.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Lieutenant S. Reznov (talkcontribs)

I just tried running that script with the command

WIKI=wikihost_mywikiBattlefield php maintenance/install.php --pass=*************** Battlefield_Wiki Inquisitor_Ehrenstein

And I get this error:

PHP Fatal error:  Call to a member function getDB() on a non-object in /home/sasha/web_servers/mywiki.ssu.lt/www/extensions/SimpleFarm/includes/SimpleFarm.php on line 164
Fatal error: Call to a member function getDB() on a non-object in /home/sasha/web_servers/mywiki.ssu.lt/www/extensions/SimpleFarm/includes/SimpleFarm.php on line 164

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Danwe (talkcontribs)

I think I committed a patch for this error about two weeks ago to the git repo. But even then, this will still not work. I tried this myself now and you have to proceed as follows

  • temporarily rename your localsettings.php
  • run the install.php script, e.g. php maintenance/install.php wikiname wikiadmin --pass=adminpw --dbname=test --dbuser=user --dbpass=***. Any other parameters used here should be compliant to your actual localsettings or to your new farm member's settings (see next point)
  • enter your new Wiki to your $egSimpleFarmMembers, make sure you use settings compliant to any additional parameters used in the install script
  • delete the newly created localsettings.php and reinstate your old one

Now, this should really work, though, very inconvenient. I might work on a script simplifying this, though this script should be heavily tested, so I won't get around getting this done before next month.

Lieutenant S. Reznov (talkcontribs)

Thanks. I'll try that. When you get a better method implemented, that will be good. I'm working on building a wiki hosting service, so I'm looking for a way of quickly implementing new wikis upon request.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Lieutenant S. Reznov (talkcontribs)

The database now seems to be created, but I get a message saying that there is no farm member at the wiki location.

http://battlefield.mywiki.ssu.lt/Main_Page

I have this listed in the farm members file:

array(
                'name' => 'Battlefield_Wiki',
                'db' => 'wikihost_mywikiBattlefield',
                'addresses' => array( 'battlefield.mywiki.ssu.lt' ),
                'maintain' => false,
        ),

I have the database user set to use all the databases with the same prefix, so it works for all of them. Do I still need to set the user in this file?

EDIT

I'm getting a database error, even though I've added this:

array(
                'name' => 'Battlefield_Wiki',
                'wgDBprefix' => '',
                'db' => 'wikihost_mywikiBattlefield',
                'addresses' => array( 'battlefield.mywiki.ssu.lt' ),
                'maintain' => false,
        ),

EDIT

For some reason, it won't let me set database prefix per wiki.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Lieutenant S. Reznov (talkcontribs)

Thank you, it seems that I've finally figured it out. I needed to make sure that I was setting the prefix in the installation script. I've also saved the command used for installation to reuse to make the process easier. I could probably also work on a shell script that could be used to simplify the process. Ideally I could make a script that only required inputing the database name and the wiki name.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Danwe (talkcontribs)

That would be great!

I don't get how you did the thing with the DB prefixes though. As far as I remember, my extension does not support shared databases with several wikis but different table prefixes for technical reasons ఠ_ఠ

Lieutenant S. Reznov (talkcontribs)

I'm using separate databases, but I have mw_ as the table prefix. I forgot to add this when running the install script, which resulted in having different prefixes on each database. The extension seems to only be able to handle one prefix; it can't be set per wiki.

I could put together a shell script fairly quickly, though my ultimate goal would be to make a secondary extension that adds a form for allowing users to create new wikis on their own. There would be issues with getting the extension to securely run a shell script with input from the form. I don't actually know if it's possible for PHP to run a shell script, plus I have obvious security concerns. I'll add a link on the extension page if I can get it set up.

Do you know if this extension can work with a shared user table for global accounts? It would make it much easier to manage wiki administrators, especially with a global staff group.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Lieutenant S. Reznov (talkcontribs)

I just created a basic script for reducing wiki creation to a single command. It would work better for users to substitute variables that would remain constant during wiki creation to allow for an easier creation.

https://gist.github.com/Inquisitor-Sasha/7348768

I'll also write about putting the script into user/bin so all users need to do is navigate to the wiki directory and type make-wiki followed by the command arguments.

Eventually I'll work on implementing the script in an extension to take input from a form so that web users can create new wikis directly on their own. I'll also need to look into a way to then add the new wiki code to FarmMembers.php.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein/Александры реактион.

Lieutenant S. Reznov (talkcontribs)
Danwe (talkcontribs)
Lieutenant S. Reznov (talkcontribs)

When I run the command

php maintainFarm.php "/home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/update.php" --farmonly=wikihost_mywikiBattlefield

I get this

~~
~~ Simple Farm NOTE: No farm member selected in 'WIKI' environment var.
~~                   Auto-selected main member 'wikihost_mywikiBattlefield'.
~~

~~ The following 1 out of 2 farm members are selected:
~~ (1) Name: 'Battlefield_Wiki' DB: 'wikihost_mywikiBattlefield'

~~ Start maintaining selected 'Simple Farm' members:
~~ Command: '/home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/update.php'

~~ (1/1) Running command for member 'Battlefield_Wiki' (WIKI=wikihost_mywikiBattlefield)...

sh: 1: /home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/update.php: Permission denied


~~ Finished! All 1 selected 'Simple Farm' members have been maintained
~~ WARNING: 1 of the command executions have returned a value implying an error. See output above!

There are no tables added to the database.

This post was posted by Lieutenant S. Reznov, but signed as Inquisitor Ehrenstein.

Danwe (talkcontribs)

This is the wrong command, you need to use php in front of the update script!

Reply to "Is there a way to make this use the same database for the wikis?"