[Tool]Dedicated Manager Web site

Moderator: NADEO

User avatar
w1lla
Posts: 2385
Joined: 15 Jun 2010, 11:09
Location: Netherlands
Contact:

Re: [Tool]Dedicated Manager Web site

Post by w1lla » 26 Jan 2015, 11:41

The_Big_Boo wrote:
w1lla wrote:

Code: Select all

manialive.plugins[] = 'eXpansion\Shootmania'
manialive.plugins[] = 'eXpansion\Shootmania\Matchs'
A plugin is in a subfolder 'author/plugin-name' and there shouldn't be any exception. I don't know what you're trying to do but I'm surprised there isn't any check on ManiaLive start to prevent loading plugins in a too deep folder. Nevertheless, both will have the same id in ManiaLive so there's a lot of things which can go wrong (events, public method calls, ...) So the Dedicated Manager behaviour is actually correct.


About the title selection in quick start, it's already in the config file. It may be an idea to let the possibility to override it though.
Fixed it myself.

For example eXpansion has a issue with this aswell.

A solution is this:

Code: Select all

<?php
/**
 * @copyright   Copyright (c) 2009-2012 NADEO (http://www.nadeo.com)
 * @license     http://www.gnu.org/licenses/lgpl.html LGPL License 3
 * @version     $Revision$:
 * @author      $Author$:
 * @date        $Date$:
 */

namespace DedicatedManager\Services;

class ManialiveService extends AbstractService
{
	/**
	 * @return string[]
	 */
	function getPlugins()
	{
		$manialivePath = \DedicatedManager\Config::getInstance()->manialivePath;
		require $manialivePath.'libraries/autoload.php';

		$availablePlugins = array();

		foreach($this->searchFolderForPlugin($manialivePath.'libraries/ManiaLivePlugins') as $plugin)
			if(($class = $this->validatePlugin($plugin)) !== false)
				$availablePlugins[] = $class;

		return $availablePlugins;
	}

	/**
	 * @param string $configFile
	 * @param mixed[] $options
	 * @return int
	 * @throws \Exception
	 */
	function start($configFile, array $options = array())
	{
		$config = \DedicatedManager\Config::getInstance();
		$isWindows = stripos(PHP_OS, 'WIN') === 0;
		if($isWindows)
			$startCommand = 'START php.exe bootstrapper.php';
		else
			$startCommand = 'php bootstrapper.php';
		$startCommand .= ' --manialive_cfg='.escapeshellarg($configFile.'.ini');
		
		foreach($options as $key => $value)
			$startCommand .= ' --'.$key.'='.escapeshellarg($value);
		
		if(!$isWindows)
			$startCommand .= ' &';
		
		// Getting current PIDs
		$currentPids = $this->getPIDs();
		
		// Starting dedicated
		$procHandle = proc_open($startCommand, array(), $pipes, $config->manialivePath);
		proc_close($procHandle);

		// Getting its PID
		$diffPids = array_diff($this->getPIDs(), $currentPids);
		if(!$diffPids)
			throw new \Exception('Can\'t start dedicated server.');
		return reset($diffPids);
	}
	
	/**
	 * @param int $pid
	 */
	function stop($pid)
	{
		$isWindows = stripos(PHP_OS, 'WIN') === 0;
		if($isWindows)
			`TASKKILL /PID $pid`;
		else
			`kill -9 $pid`;
	}
	
	/**
	 * @param string $plugin
	 * @return string|bool
	 */
	private function validatePlugin($plugin)
	{
		$matches = array();
		if(preg_match('/(ManiaLivePlugins.*)\.php/', $plugin, $matches))
		{
			$class = '\\'.str_replace('/', '\\', $matches[1]);
			if(class_exists($class) && is_subclass_of($class, '\ManiaLive\PluginHandler\Plugin'))
				return implode('\\', array_slice(explode('\\', $class), 1, 4));
			else
				return false;
		}
	}

	/**
	 * @param string $folder
	 * @return string[]
	 */
	private function searchFolderForPlugin($folder)
	{
		$plugins = array();

		$path = explode(DIRECTORY_SEPARATOR, $folder);
		$parent = end($path);

		foreach(scandir($folder) as $file)
		{
			if($file == '.' || $file == '..' || $file == '...')
				continue;

			$filePath = $folder.DIRECTORY_SEPARATOR.$file;
			//If it's a directory digg deeper
			if(is_dir($filePath))
				$plugins = array_merge($plugins, $this->searchFolderForPlugin($filePath));
			else
			{
				$pathParts = pathinfo($filePath);
				//If the file got the name of the parent folder or is called Plugin it should be a Plugin
				if($pathParts['filename'] == $parent || $pathParts['filename'] == 'Plugin')
					$plugins[] = $filePath;
			}
		}

		return $plugins;
	}

	/**
	 * @return int[]
	 */
	private function getPIDs()
	{
		if(stripos(PHP_OS, 'WIN') === 0)
		{
			$dedicatedProc = `TASKLIST /FI "IMAGENAME eq php.exe" /NH`;
			if(preg_match_all('/php\.exe\s+(\d+)/m', $dedicatedProc, $matches))
				return $matches[1];
		}
		else
		{
			$dedicatedProc = `ps -C "php" --format pid --no-headers --sort +cputime`;
			if(preg_match_all('/(\\d+)/', $dedicatedProc, $matches))
				return $matches[1];
		}
		return array();
	}
}

?>
Made the array_slice search for values between 1 and 4. Actually this works for eXpansion and other plugins that are coded this way.

file changed: maniaplanet-dedicated-manager\libraries\DedicatedManager\Services\ManialiveFileService.php

But its not the ideal combination.
TM² Info
SM Info
QM Info

OS: Windows 10 x64 Professional
MB: MSI 970A-G46
Processor: AMD FX-6300 3500 mHz
RAM Memory: 16 GB DDR3
Video: SAPPHIRE DUAL-X R9 280X 3GB GDDR5
KB: Logitech G510s
Mouse: Logitech G300s
Mode Creation
ManiaScript Docs

User avatar
w1lla
Posts: 2385
Joined: 15 Jun 2010, 11:09
Location: Netherlands
Contact:

Re: [Tool]Dedicated Manager Web site

Post by w1lla » 09 Feb 2015, 13:28

TM² Info
SM Info
QM Info

OS: Windows 10 x64 Professional
MB: MSI 970A-G46
Processor: AMD FX-6300 3500 mHz
RAM Memory: 16 GB DDR3
Video: SAPPHIRE DUAL-X R9 280X 3GB GDDR5
KB: Logitech G510s
Mouse: Logitech G300s
Mode Creation
ManiaScript Docs

User avatar
gsxroil
Posts: 67
Joined: 21 May 2011, 19:43

Re: [Tool]Dedicated Manager Web site

Post by gsxroil » 05 May 2015, 22:56

Hellos,

I installed hard dedicated manager and I have a problem

For starters how can we add a login to access the player via web services manager

Also I would like to make ManiaLive eXpansion but it does not work very well, here are the cases


1) Booting from -Start a new server- and since Ingame controllers option on a server already online

The first problem to select the Autoload plugin I have to run it from the "Configure plugins" option

but it does not work

Code: Select all

 There Seems be a problem while Establishing a MySQL connection.
 
 Advanced details
 File: connection.php
 Line: 54
 Message: There is no class for the database connection like "MySQLi" yet 
2) Where do I start all at the same time from "Quick start a new server" with a dedi.cfg and expansion. ini

already configured by hand and bdd already created it starts out the 2 services, but if I cut expansion or if it crashes I have to board

quick start by a new server reboot so all


Bonjours,

j'ai installé difficilement dedicated manager et j'ai quelque probleme

Pour commencer comment peut on ajouter une login joueur pour acceder au manager via web services

Aussi je voudrais lancer manialive eXpansion mais ca ne fonctionne pas tres bien, voici les cas


1) Demarrage depuis -Start a new server- et depuis l'option Ingame controllers sur un server deja en ligne

1er probleme pour selectionner le plugin Autoload je dois le lancer depuis l'option "Configure plugins"

mais ca ne fonctionne pas

Code: Select all

There seems be a problem while establishing a MySQL connection.
 
 Advanced details
 File: Connection.php
 Line: 54
 Message: There is no connection class for the database type "MySQLI" yet!

2) Si je demarre le tout en meme temps depuis " Quick start a new server" avec un dedi.cfg et un expansion. ini

deja configuré a la main et une bdd deja crée ca demarre bien les 2 services mais si je coupe expansion ou si il plante je dois repasser

par quick start a new server donc tout redemarrer

User avatar
farfa
Nadeo
Nadeo
Posts: 601
Joined: 14 Jun 2010, 16:15
Location: In front of your hood with one lap late

Re: [Tool]Dedicated Manager Web site

Post by farfa » 06 May 2015, 07:37

Hi,
Can you be more precise with this sentence ?
For starters how can we add a login to access the player via web services manager
For your other questions I think it's more related to eXpension, and I can't help you with those problems
Also known as: satanasdiabolo

User avatar
gsxroil
Posts: 67
Joined: 21 May 2011, 19:43

Re: [Tool]Dedicated Manager Web site

Post by gsxroil » 06 May 2015, 10:15

OUi effectivement je vais preciser desolé .

dans /manager/app.ini j'ai configuré

Code: Select all

DedicatedManager\Config.dedicatedPath = /opt/maniaplanet-server/
DedicatedManager\Config.manialivePath = /opt/manialive/
DedicatedManager\Config.maniaConnect = on
DedicatedManager\Config.admins[] = 'monlogin'
; If maniaConnect is On, you need to create an API username and an application with this username
 webservices.username = 'login|username'
 webservices.password = 'monpwd'
Ca fonctionne parfaitement pour me connecter au manager avec mon login mais je veux donner l'acces a un autre login maniaplanet

comment faire ?


Et pour expansion peut il etre demarré via le manager etant une extension de manialive ?

User avatar
farfa
Nadeo
Nadeo
Posts: 601
Joined: 14 Jun 2010, 16:15
Location: In front of your hood with one lap late

Re: [Tool]Dedicated Manager Web site

Post by farfa » 06 May 2015, 10:26

Hi,
If you want to give admin access to the tool, just add this line in you app.ini

Code: Select all

DedicatedManager\Config.admins[] = 'an_other_login'
Your app.ini file will looks like that

Code: Select all

DedicatedManager\Config.dedicatedPath = /opt/maniaplanet-server/
DedicatedManager\Config.manialivePath = /opt/manialive/
DedicatedManager\Config.maniaConnect = on
DedicatedManager\Config.admins[] = 'monlogin'
DedicatedManager\Config.admins[] = 'an_other_login'
; If maniaConnect is On, you need to create an API username and an application with this username
webservices.username = 'login|username'
webservices.password = 'monpwd'
Also known as: satanasdiabolo

User avatar
gsxroil
Posts: 67
Joined: 21 May 2011, 19:43

Re: [Tool]Dedicated Manager Web site

Post by gsxroil » 06 May 2015, 10:40

Thank you :thumbsup:

User avatar
w1lla
Posts: 2385
Joined: 15 Jun 2010, 11:09
Location: Netherlands
Contact:

Re: [Tool]Dedicated Manager Web site

Post by w1lla » 06 May 2015, 22:14

MySqli support can be handled through the following .zip: http://tmrankings.com/mp/maniaplanet_de ... vendor.zip

Just unzip it in the main folder where the other folders are in your dedicated manager.

To let expansion run:

Just edit file: maniaplanet-dedicated-manager\libraries\DedicatedManager\Services\ManialiveService line 90 and replace it with this:

Code: Select all

return implode('\\', array_slice(explode('\\', $class), 1, 4));
That will make it work eventually.
TM² Info
SM Info
QM Info

OS: Windows 10 x64 Professional
MB: MSI 970A-G46
Processor: AMD FX-6300 3500 mHz
RAM Memory: 16 GB DDR3
Video: SAPPHIRE DUAL-X R9 280X 3GB GDDR5
KB: Logitech G510s
Mouse: Logitech G300s
Mode Creation
ManiaScript Docs

User avatar
gsxroil
Posts: 67
Joined: 21 May 2011, 19:43

Re: [Tool]Dedicated Manager Web site

Post by gsxroil » 08 May 2015, 01:01

thank you very much it works perfectly for the autoload plugin :thumbsup:


the zip you gave me has not solved the problem mysqli, I always error

Code: Select all

There Seems be a problem while Establishing a MySQL connection.
 
 Advanced details
 File: connection.php
 Line: 54
 Message: There is no class for the database connection like "MySQLi" yet
I solved the problem by adding a line 117 in ManialiveFileService.php for MySQL specify the config.ini

Code: Select all

fprintf($f, "database.type = '%s'\n\n", 'MySQL');
it is important to make the necessary to work with MySQLI ?



ps: ty google translate :?

crack12321
Posts: 6
Joined: 20 Aug 2014, 23:19

Re: [Tool]Dedicated Manager Web site

Post by crack12321 » 22 Nov 2016, 11:49

tried to download this :S :D but there isnt a Setup.php anymore :S

can u tell me how to install it? o.O

thanks ;)

Post Reply

Return to “Dedicated Server”

Who is online

Users browsing this forum: No registered users and 1 guest