ManiaLive r2028

Discuss the Dedicated Server Tools developed by Nadeo Live such as ManiaLive, Trust Circles, Dedicated Manager, Competition Manager and Lobbies

Moderator: NADEO

nocturne
Posts: 208
Joined: 23 Jun 2010, 21:31

Re: ManiaLive r2028

Post by nocturne »

Slig beat me to the punch... :lol:

Every single other php controller in the history of TM has used the simple context 'php xxxx.php </dev/null >some.log 2>&1 &'. The format is STDIN=0 (less than), STDOUT=1 (more than), and STDERROR=2. So in that context the input would be null, the output would be put into a log file, and errors would be redirected into the output channel (2>&1). I typically only use nohup for testing, and forgot about screen.

I'm just wondering if the process needs to receive any input (have no idea how the threading is handled)...
User avatar
Slig
Posts: 637
Joined: 15 Jun 2010, 11:52
Location: TraXicoLand

Re: ManiaLive r2028

Post by Slig »

nocturne wrote: (have no idea how the threading is handled)...
I looked the source about it few days ago : it seems to be done by launching other php processes (no other way as php sadly still not have real multithread), and that sqlite is needed to transmit datas between processes (i think, as it is difficult to understand clearly with all clesses and subclasses involved). It seems to be some very complex and interesting part written by Flo, perhaps that he will read that thread and give us more details about it (essentially about how datas and signals are shared by processes)
User avatar
aseco
Posts: 96
Joined: 06 Jul 2010, 17:08
Location: Germany
Contact:

Re: ManiaLive r2028

Post by aseco »

Slig wrote:
nocturne wrote: (have no idea how the threading is handled)...
I looked the source about it few days ago : it seems to be done by launching other php processes (no other way as php sadly still not have real multithread), and that sqlite is needed to transmit datas between processes (i think, as it is difficult to understand clearly with all clesses and subclasses involved). It seems to be some very complex and interesting part written by Flo, perhaps that he will read that thread and give us more details about it (essentially about how datas and signals are shared by processes)
The threading system indeed works by starting php childprocesses and let them communicate with the main process using sqlite. There is slightly differences for linux and windows behaviour.
On linux I have to check from the childprocesses if the main process is still running, this is done every second. Now when the main process is stopped all childs will exit. Without that check, you could have killed the main process but still have all threads running.

To be able to pass work to a thread you create a class that contains a method run(). This class needs to be instanciated, serialized and written into the database. Depending on the properties of this class it >can< be quite big, but normally it will be < 200 characters.
Child processes are checking the database regularly for new jobs and if there is one or more, they will take them in correct order, unserialize the objects and call the run method.
(there is some tricky stuff on which threads can get which jobs and that the jobs are fairly shared between the threadpool, but this is much detail. Also I won't be talking about the timings and the concrete realization, you can see the code for all details^^)
If the result is there it will once again be serialized and put back into the database.
The "ThreadPool" on the main process checks the results, removes them from the database and calls back with the command objects (that now have the result of the calculation).

The ThreadPool also keeps track of the thread's states. before a command is sent to a process, a ping is sent to check whether the process is still alive. another integrity check is that the ThreadPool knows when a command has been sent to a process and how long it is currently processing it.
If either a Thread is working too long or a ping is not being answered for a given time the thread will be "killed" (which means an intern exit signal is sent). A new thread will be started and the commands that have failed will be retransmitted. (If the killed thread will send some results after it has been killed they will be ignored). The threading system is not too fast, but one requirement was, that it should not loose any jobs :-)

EDIT: Thanks Slig and nocturne for the details on how to launch a detached process on linux!
i7 920 | Nvidia GTX260 | 4Gb DDR3
www.floschnell.de | I like that comic
JagaMan
Posts: 11
Joined: 04 Feb 2011, 15:16

Re: ManiaLive r2028

Post by JagaMan »

Hy all !
i can't understand how this ManiaLive works, when i use 'php bootstrapper.php' it give's me this : "PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /games/ManiaLive/bootstrapper.php on line 20
PHP Parse error: syntax error, unexpected T_STRING in /games/ManiaLive/bootstrapper.php on line 20"
When i use './run' it give's me this: "Launching ManiaLive Daemon with the following arguments:
./run: line 71: start-stop-daemon: command not found"

So frustrating... I'm trying to solve this for to long time, i think i will give up.
farfa
Nadeo
Nadeo
Posts: 585
Joined: 14 Jun 2010, 16:15
Location: In front of your hood with one lap late

Re: ManiaLive r2028

Post by farfa »

This error only happen if you are running a php version which is anterior to php5.3.
Which Linux distribution do you use ? Which version of PHP do you use ?
Also known as: satanasdiabolo
JagaMan
Posts: 11
Joined: 04 Feb 2011, 15:16

Re: ManiaLive r2028

Post by JagaMan »

Hi again all :)
Thx to farfa i succed upgrading php to 5.3 but now i have some errors with ManiaLive maybe someone can help me

My Config.ini :

Code: Select all

;------------------
; ManiaLive
;------------------

; the default path is 'php.exe' on windows and 'php' on linux
 phpPath = /usr/bin/php

; the default is %application%/logs
 logsPath = /var/logs

; whether to write console output into a file, default is Off
 runtimeLog = On

;------------------
; Dedicated Server
;------------------

 server.host = '93.114.174.21'

 server.port = 7005

; standard user level is SuperAdmin
 server.user = 'SuperAdmin'

 server.password = '------'

; when a connection can't be established after the given amount
; of time, it will timeout and manialive will shutdown.
 server.timeout = 1

;------------------
; Admins
;------------------

; Add admins, that shall be able to control your server from game.
 admins.logins[] = 'jaga01'

;------------------
; Plugins
;------------------

; Add plugins to load.
; plugins.load[] = 'Author\PluginName'

;------------------
; Threading
;------------------

; threading can improve performance of your application. it
; allows modules to push blocking work onto another processes,
; this can also improve stability, because timeouts or
; unexpected exceptions do not impact the main application.

; if you have stability problems try to deactivate threading first
threading.enabled = true

; how long may a thread be busy until it is killed
 threading.busy_timeout = 20

; how long, if not busy, may it take for a thread to response to a ping
 threading.ping_timeout = 2

; how many jobs should be send on each loop.
; increasing this value will boost jobs/time
; decreasing it will result in a reaction time improvement.
 threading.chunk_size = 10

; if threading is disabled, then how much time should be spend on
; each application loop to process work that would have been assigned
; to other threads normally
; default value is 1 second.
 threading.sequential_timeout = 1

;------------------
; ManiaHome
;------------------

; enabling the maniahome feature allows other modules to send
; notifications about eg. records or other actions on your
; server to player's friends.

; disabled by default.
; maniahome.enabled = true

; maniahome.user = ''

; maniahome.password = ''

; maniahome.manialink = ''

;------------------
[hostname: testHost]
;------------------

; put here the configuration specific to an host
And the errors :

Code: Select all

-> ErrorException with code 0
    file_get_contents(): http:// wrapper is disabled in the server
      configuration by allow_url_fopen=0
  - in /games/ML/libraries/ManiaLive/Features/Updater.php on line 56
  - Stack: #0 [internal function]:
      ManiaLive\Application\ErrorHandling::createExcpetionFromError(2,
      'file_get_conten...', '/games/ML/libra...', 56, Array)
           #1 /games/ML/libraries/ManiaLive/Features/Updater.php(56):
      file_get_contents('http://manialin...')
           #2 /games/ML/libraries/ManiaLive/Features/Updater.php(41):
      ManiaLive\Features\Updater->checkUpdate()
           #3 /games/ML/libraries/ManiaLive/Features/Tick/Event.php(26):
      ManiaLive\Features\Updater->onTick()
           #4 /games/ML/libraries/ManiaLive/Event/Dispatcher.php(52):
      ManiaLive\Features\Tick\Event->fireDo(Object(ManiaLive\Features\Updater))
           #5 /games/ML/libraries/ManiaLive/Features/Tick/Ticker.php(32):
      ManiaLive\Event\Dispatcher::dispatch(Object(ManiaLive\Features\Tick\Event
      ))
           #6 /games/ML/libraries/ManiaLive/Application/Event.php(36):
      ManiaLive\Features\Tick\Ticker->onPreLoop()
           #7 /games/ML/libraries/ManiaLive/Event/Dispatcher.php(52):
      ManiaLive\Application\Event->fireDo(Object(ManiaLive\Features\Tick\Ticker
      ))
           #8
      /games/ML/libraries/ManiaLive/Application/AbstractApplication.php(112):
      ManiaLive\Event\Dispatcher::dispatch(Object(ManiaLive\Application\Event))
           #9 /games/ML/bootstrapper.php(20):
      ManiaLive\Application\AbstractApplication->run()
           #10 {main}
Best regards !
Jaga :mrgreen:
User avatar
Knutselmaaster
Posts: 1206
Joined: 15 Jun 2010, 18:03
Location: Somewhere between Paris and Disney in France.
Contact:

Re: ManiaLive r2028

Post by Knutselmaaster »

In your php.ini set

Code: Select all

allow_url_fopen=true
JagaMan
Posts: 11
Joined: 04 Feb 2011, 15:16

Re: ManiaLive r2028

Post by JagaMan »

Ty Knutselmaaster
But now it gives me this:

Code: Select all

Launching ManiaLive with the following arguments:
[12:08:53] XML-RPC connection established
[12:08:54] Successfully authentified with XML-RPC server

then i can't write nothing anymore, is it normal ?
User avatar
Knutselmaaster
Posts: 1206
Joined: 15 Jun 2010, 18:03
Location: Somewhere between Paris and Disney in France.
Contact:

Re: ManiaLive r2028

Post by Knutselmaaster »

JagaMan wrote:Ty Knutselmaaster
But now it gives me this:

Code: Select all

Launching ManiaLive with the following arguments:
[12:08:53] XML-RPC connection established
[12:08:54] Successfully authentified with XML-RPC server

then i can't write nothing anymore, is it normal ?
Yes, it runs.
But as you don't load any plugin, nothing more will happen.
And you will never be able to write anything in your console, it just shows what is happening in the servers process.

This setting is a linux only setting, and even there it in not necessary:

Code: Select all

; the default is %application%/logs
logsPath = /var/logs
You should leave it on the standard setting so that the log files remain in the ManiaLive/logs folder:

Code: Select all

; the default is %application%/logs
;logsPath = /var/logs
As a general rule for the settings, if you leave the semicolon ( ; ) in front, it will use the standard setting.
So this:

Code: Select all

; standard user level is SuperAdmin
server.user = 'SuperAdmin'
Has no function at all (it will still work of course), since SuperAdmin is already the user if you leave the standard setting.

Code: Select all

; standard user level is SuperAdmin
;server.user = 'SuperAdmin'
Now, to make your plugins run, add them into the config.ini:

For example:

Code: Select all

;------------------
; Plugins
;------------------

; Add plugins to load.
; plugins.load[] = 'Author\PluginName'

plugins.load[] = 'Standard\PluginManager'

plugins.load[] = 'Standard\Profiler'

plugins.load[] = 'Standard\Menubar'
The plugins (in a folder with the same name) need to be in ./libraries/ManiaLivePlugins
For example the plugins that i set in the config.ini above need to be in:
/libraries/ManiaLivePlugins/Standard/PluginManager/
/libraries/ManiaLivePlugins/Standard/Profiler/
/libraries/ManiaLivePlugins/Standard/Menubar/

In those folders you will find a .php file with the same name, and optionally some other files/folders.

Plugins which need settings, will need those settings right below the plugin name:

Code: Select all

plugins.load[] = 'Standard\Dedimania'
plugins.Standard\Dedimania.password = 'Pass-of-the-serverlogin'
plugins.Standard\Dedimania.notifications = 'On'
plugins.Standard\Dedimania.notifyNewFirstRecord = '%player% drove new first Dedimania record with a time of %time%!'
plugins.Standard\Dedimania.notifyNewRecord = '%player% just ranked %rank% on Dedimania with a time of %time%!'
plugins.Standard\Dedimania.notifyImprovedFirstRecord = '%player% beat his own first Dedimania record with a time of %time%!'
plugins.Standard\Dedimania.notifyImprovedRecord = '%player% moved on the %rank% Dedimania rank by finishing with a time of %time%!'
plugins.Standard\Dedimania.notifyImprovedRecordTimeOnly = '%player% secured his %rank% Dedimania rank by driving a time of %time%!'
Last edited by Knutselmaaster on 05 Feb 2011, 13:43, edited 1 time in total.
Reason: Correction
JagaMan
Posts: 11
Joined: 04 Feb 2011, 15:16

Re: ManiaLive r2028

Post by JagaMan »

nice tutorial for noobs like me :)

i added FreezonePlugin but is closing after i activate it

this is what i saw when i started it :

Code: Select all

[14:48:11] XML-RPC connection established
[14:48:11] Successfully authentified with XML-RPC server
Threading will be disabled, enable the 'SQLite' extension on your system!
[Attention] Threading disabled - this may cause performance issues!
do you know any tutorial from where i can activate that extensions ? :(

ty in advance
Post Reply

Return to “Dedicated Server Tools”

Who is online

Users browsing this forum: No registered users and 1 guest