Will not boot with shared database computer asleep
#1
I'm running the following version of openelec.

Starting XBMC (12.2 Git:32b1a5e), Platform: Linux (OpenELEC (official) - Version: 3.0.6, 3.6.11 armv6l). Built on Jun 14 2013

I have another PC that is based off of xbmcbuntu in the house and is currently a version of 12.2 frodo. While they do have different build dates, according to the wiki, I assume as long as the database versions are the same, I wont have a problem with one upgrading and breaking the other.

I didnt have any problems setting up the MySQL server on my windows machine that hosts all my media and now the msql database as well. The other xbmcbunutu machine i dont think has a problem because it goes to sleep and is able to wake up and then run a WOL command using the Advanced WOL addon.

I have the same setup for my raspberry pi, however since its a fresh boot, it doesnt run the WOL command until xbmc gets loaded. In the mean time, I see in the logs that it cannot connect to the mySQL server, which is true as the pc is asleep. The problem i have, shouldnt xbmc be able to boot so that it can then wake up that particular pc and then connect to the database? Or is there a way to achieve this? Or am I having an issue where the database keeps wanting to upgrade for some reason?

When i coverted to using MySQL, i found a tutorial as well as the wiki and created new profiles: Master, Adult, Kids. So to complicate things I am using a <name> tag in the advancedsettings.xml as well.

MySQL tables:
Code:
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| adultmusic32       |
| adultvideo75       |
| mysql              |
| performance_schema |
| test               |
+--------------------+
6 rows in set (0.00 sec)

Here is the sample of the log at startup. I woke the pc up during the middle of raspberry pi starting.
Code:
14:22:02 T:3047784448  NOTICE: Found resolution 1152 x 720 for display 0 with 1440 x 900 @ 60.000000 Hz
14:22:02 T:3047784448  NOTICE: Found resolution 1152 x 720 for display 0 with 1680 x 1050 @ 60.000000 Hz
14:22:02 T:3047784448  NOTICE: Found resolution 1280 x 720 for display 0 with 1600 x 900 @ 60.000000 Hz
14:22:02 T:3047784448  NOTICE: Found ([email protected]) at 19, setting to RES_DESKTOP at 16
14:22:02 T:3047784448  NOTICE: Checking resolution 16
14:22:02 T:3047784448  NOTICE: GL_VENDOR = Broadcom
14:22:02 T:3047784448  NOTICE: GL_RENDERER = VideoCore IV HW
14:22:02 T:3047784448  NOTICE: GL_VERSION = OpenGL ES 2.0
14:22:02 T:3047784448  NOTICE: GL_SHADING_LANGUAGE_VERSION = OpenGL ES GLSL ES 1.00
14:22:02 T:3047784448  NOTICE: GL_EXTENSIONS = GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_texture_npot GL_OES_depth24 GL_O
ES_vertex_half_float GL_OES_EGL_image GL_OES_EGL_image_external GL_EXT_discard_framebuffer GL_OES_rgb8_rgba8 GL_OES_depth32 GL_OES_mapbuffer GL_EXT_texture_f
ormat_BGRA8888 GL_APPLE_rgb_422 GL_EXT_debug_marker
14:22:07 T:3047784448  NOTICE: Running database version Addons15
14:22:07 T:3047784448  NOTICE: Running database version ViewModes4
14:22:07 T:3047784448  NOTICE: Running database version Textures13
14:22:07 T:2955670624  NOTICE: Thread CEC Adapter Update Thread start, auto delete: false
14:22:10 T:3047784448   ERROR: Unable to open database: AdultMusic32 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:22:13 T:3047784448   ERROR: Unable to open database: AdultMusic31 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:22:16 T:3047784448   ERROR: Unable to open database: AdultMusic30 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:22:19 T:3047784448   ERROR: Unable to open database: AdultMusic29 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:22:22 T:3047784448   ERROR: Unable to open database: AdultMusic28 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:22:25 T:3047784448   ERROR: Unable to open database: AdultMusic27 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:22:28 T:3047784448   ERROR: Unable to open database: AdultMusic26 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:22:31 T:3047784448   ERROR: Unable to open database: AdultMusic25 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:22:34 T:3047784448   ERROR: Unable to open database: AdultMusic24 [2003](Can't connect to MySQL server on '192.168.1.108' (113))
14:23:25 T:3047784448  NOTICE: Running database version AdultVideo75
14:23:25 T:3047784448  NOTICE: Running database version TV22
14:23:25 T:3047784448  NOTICE: Running database version Epg7
14:23:25 T:3047784448  NOTICE: start dvd mediatype detection
14:23:25 T:3047784448  NOTICE: initializing playlistplayer
14:23:25 T:3047784448  NOTICE: DONE initializing playlistplayer
14:23:25 T:3020039264  NOTICE: Thread CDetectDVDMedia start, auto delete: false
14:23:28 T:2937398368  NOTICE: Thread XBPyThread start, auto delete: false
14:23:28 T:3047784448  NOTICE: Previous line repeats 4 times.
14:23:28 T:3047784448  NOTICE: initialize done
14:23:28 T:3047784448  NOTICE: Running the application...
14:23:28 T:2903843936  NOTICE: Thread XBPyThread start, auto delete: false
14:23:29 T:3047784448   ERROR: GLES: Vertical Blank Syncing unsupported
14:23:31 T:2895455328  NOTICE: Thread Jobworker start, auto delete: true
14:23:31 T:3047784448  NOTICE: Webserver: Starting...
14:23:31 T:3047784448  NOTICE: WebServer: Started the webserver
14:23:31 T:3047784448  NOTICE: ES: Starting event server
14:23:31 T:3047784448  NOTICE: starting zeroconf publishing
14:23:31 T:2828346464  NOTICE: Thread Jobworker start, auto delete: true
14:23:31 T:2836735072  NOTICE: Thread CTCPServer start, auto delete: false
14:23:31 T:2845123680  NOTICE: Thread CEventServer start, auto delete: false
14:23:31 T:2845123680  NOTICE: ES: Starting UDP Event server on 0.0.0.0:9777
14:23:31 T:2845123680  NOTICE: UDP: Listening on port 9777
14:23:31 T:2819957856  NOTICE: Thread Jobworker start, auto delete: true
14:23:32 T:2937398368  NOTICE: -->Python Interpreter Initialized<--
14:23:33 T:2945786976  NOTICE: -->Python Interpreter Initialized<--
14:23:33 T:2912232544  NOTICE: -->Python Interpreter Initialized<--
14:23:33 T:2929009760  NOTICE: -->Python Interpreter Initialized<--
14:23:33 T:2920621152  NOTICE: -->Python Interpreter Initialized<--
14:23:33 T:2903843936  NOTICE: -->Python Interpreter Initialized<--
14:23:39 T:2912232544  NOTICE: Artwork Downloader: ## Service - Run at startup: False
14:23:39 T:2912232544  NOTICE: Artwork Downloader: ## Service - Delayed startup: -- minutes
14:23:39 T:2912232544  NOTICE: Artwork Downloader: ## Service - Run as service: False
14:23:39 T:2912232544  NOTICE: Artwork Downloader: ## Service - Time: 00:00
14:23:41 T:2937398368  NOTICE: script.advanced.wol: Starting WOL script
14:23:41 T:2903843936  NOTICE:  StorageServer Module loaded RUN
14:23:41 T:2903843936  NOTICE: StorageClient-2.5.0 Starting server
14:23:41 T:2903843936  NOTICE: StorageServer-2.5.0 Storage Server starting /storage/.xbmc/userdata/profiles/Adult/addon_data/script.common.plugin.cache/commoncache.db
14:23:41 T:2937398368  NOTICE: script.advanced.wol: WakeOnLan signal sent to MAC-Address 00:1d:09:14:d2:bc
14:23:42 T:2937398368  NOTICE: script.advanced.wol: Closing WOL script
14:23:42 T:2937398368  NOTICE: script.advanced.wol: Waiting for resume from standby
14:27:18 T:2895455328  NOTICE: Thread Jobworker start, auto delete: true
Motherboard P5N7A-VM, E8400 C2D 3.0 processor. NVIDIA 9300 graphics card. OpenELEC Stable - Generic x86_64 Version:3.2.4
Reply
#2
It looks like the Advanced WOL script isn't able to run right at the very beginning before XBMC attemtps to go out on to the network - that kind of defeats it's purpose, so maybe it's simply not designed to support MySQL installations (or the design of XBMC - running plugns after databases are connected - doesn't allow such support).

Anyway, at a minimum, I would suggest adding a .config/autostart.sh script that waits until the Pi network is up before allowing XBMC to start:

Code:
#!/bin/sh

# Wait for the network to come up...
while [ -z "$(connmanctl state | grep State | grep -E "ready|online")" ]; do sleep 0.25; done; logger -t "$(basename $0)" "** Network is up **"

Once the network is safely up, you could then at the end of autostart.sh run "/storage/texturecache.py wake @network.mac=00:1d:09:14:d2:bc" (or some other script which issues a WOL magic packet) after which you need to wait however long it takes for your MySQL server to wake up (ie. "sleep 5"? "sleep 10"?).

If you can think of a way to detect when MySQL is ready (similar to the wait-for-network loop), you can reduce the wait to as little as is necessary (eg. "echo "xbmc" | telnet 192.168.1.108 3306 -l xbmc")

With this addition, XBMC should always start with a working network and with a working MySQL server.

Something like the following should work:
Code:
#!/bin/sh

# Wait for the network to come up...
while [ -z "$(connmanctl state | grep State | grep -E "ready|online")" ]; do sleep 0.25; done; logger -t "$(basename $0)" "** Network is up **"

# Wake MySQL
/storage/texturecache.py wake @network.mac=00:1d:09:14:d2:bc

# Wait for MySQL
while [ -z "$(echo "xbmc" | telnet 192.168.1.108 3306 -l xbmc 2>&1 | grep "mysql_native_password")" ]; do sleep 0.25; done; logger -t "$(basename $0)" "** MySQL is up **"
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#3
Awesome! Thanks. I'm going to give this a shot now
Motherboard P5N7A-VM, E8400 C2D 3.0 processor. NVIDIA 9300 graphics card. OpenELEC Stable - Generic x86_64 Version:3.2.4
Reply
#4
Small correction to the MySQL check (first post updated). Be careful when connecting repeatedly to the MySQL server so that you don't lock the account (log in to the MySQL server as root and execute "FLUSH HOSTS;" to clear any locks) - maybe there's a "safer" way to check remote MySQL availability.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#5
A few things. First off, i got this to work. Thanks. Secondly, i did modify things a little bit. I dont have the phython file you suggested so i found a simple WOL script online, shown below

Code:
#!/usr/bin/env python
# wol.py

import socket
import struct

def wake_on_lan(macaddress):
    """ Switches on remote computers using WOL. """

    # Check macaddress format and try to compensate.
    if len(macaddress) == 12:
        pass
    elif len(macaddress) == 12 + 5:
        sep = macaddress[2]
        macaddress = macaddress.replace(sep, '')
    else:
        raise ValueError('Incorrect MAC address format')

    # Pad the synchronization stream.
    data = ''.join(['FFFFFFFFFFFF', macaddress * 20])
    send_data = ''

    # Split up the hex values and pack.
    for i in range(0, len(data), 2):
        send_data = ''.join([send_data,
                             struct.pack('B', int(data[i: i + 2], 16))])

    # Broadcast it to the LAN.
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
    sock.sendto(send_data, ('<broadcast>', 7))


if __name__ == '__main__':
    # Use macaddresses with any seperators.
    wake_on_lan('00:1d:09:14:d2:bc')
    #wake_on_lan('0F:0F:DF:0F:BF:EF')
    #wake_on_lan('0F-0F-DF-0F-BF-EF')
    # or without any seperators.
    #wake_on_lan('0F0FDF0FBFEF')

Also, i did modify your script a bit as well. Not sure if it will bother me at this point yet, but i just put in a regular 10 sec sleep in there hoping the pc is awake by then.

autostart.sh
Code:
#!/bin/sh

# Wait for the network to come up...
while [ -z "$(connmanctl state | grep State | grep -E "ready|online")" ]; do sleep 0.25; done; logger -t "$(basename $0)" "** Network is up **"

# Wake MySQL
#/storage/texturecache.py wake @network.mac=00:1d:09:14:d2:bc
/storage/wol.py
logger -t "$(basename $0)" "** WOL Sent **"

# Wait for MySQL
#while [ -z "$(echo "xbmc" | telnet 192.168.1.108 3306 -l xbmc 2>&1 | grep "mysql_native_password")" ]; do sleep 0.25; done; logger -t "$(basename $0)" "** MySQL is up **
sleep 10

I tried creating an autoexec.py in the userdata folder as well, as xbmc is supposed to have that built in - i could not get that to work
http://forum.xbmc.org/showthread.php?tid=92525

Also, sounds like a new feature in an upcoming release also assists in this problem as well:
http://forum.xbmc.org/showthread.php?tid=124340

Thanks again!
Motherboard P5N7A-VM, E8400 C2D 3.0 processor. NVIDIA 9300 graphics card. OpenELEC Stable - Generic x86_64 Version:3.2.4
Reply
#6
The thing is you're always going to hit that 10 second delay even when the MySQL host is already up (say, if you were to reboot your Pi for some reason). Up to you though.

The rbej builds may already include the automatic WOL patch.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#7
Agreed. At least you got it working for now. I will explore making it better in the future.
Motherboard P5N7A-VM, E8400 C2D 3.0 processor. NVIDIA 9300 graphics card. OpenELEC Stable - Generic x86_64 Version:3.2.4
Reply

Logout Mark Read Team Forum Stats Members Help
Will not boot with shared database computer asleep0