FAQ  •  Register  •  Login

Unable to get serviio to run on boot Ubuntu server 11.10

<<

uid

User avatar

Serviio newbie

Posts: 13

Joined: Thu Mar 22, 2012 8:47 pm

Location: 53°08´56" N 16°42´40" E

Post Fri Mar 23, 2012 8:10 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

serviio-buddy wrote:I may try your suggestion as I've just installed the 12.04 Desktop Precise Daily Build.

I congratulate ;-)

serviio-buddy wrote:Please note that the problem these users reported in this thread was "Unable to get serviio to run on boot Ubuntu server 11.10". They are using the headless Ubuntu Server 11.10 edition, not the desktop edition.

Yes I know, I know the topic.

serviio-buddy wrote:Previously, I posted that I used the wiki install guide for Ubuntu 11.10 Server and Serviio automatically loaded up boot using Ubuntu 11.10 Desktop and Ubuntu 11.10 Server with Gnome installed.
When I tried the wiki install guide again on the Ubuntu 11.10 Server (headless version), Serviio would not automatically start on reboot.

I understand. But no way I can now install a version of 'server' and practice issue. I only gave a proposal to test. Still using a version of dektop I removed the entries from /etc /rc.local, I added /etc/init/serviio.conf, I ran the machine again and it works. My /etc/init/serviio.conf:
  Code:
# Serviio - media server
#
# Serviio is a free media server. It allows you to stream your media files
# (music, video or images) to renderer devices (e.g. a TV set, Bluray player,
# games console or mobile phone) on your connected home network.

description     "serviio - media server"
author          "Rafał Szkodziński <uid@atnus.com>"

start on        (starting network-interface
                or starting network-manager
                or starting networking)

stop on         runlevel [!023456]

script
        exec    /usr/local/bin/serviio-0.6.2/bin/serviio.sh
end script


  Code:
root@poligon:~# initctl list | grep serviio
serviio start/running, process 818
root@poligon:~# ps aux | grep serviio
root       818  0.0  0.0   4392   604 ?        Ss   20:39   0:00 /bin/sh /usr/local/bin/serviio-0.6.2/bin/serviio.sh
root       845  1.3  4.0 1237960 82288 ?       Sl   20:39   0:21 java -Xmx384M -Xms20M -XX:+UseParNewGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dderby.system.home=/usr/local/bin/serviio-0.6.2/library -Dserviio.home=/usr/local/bin/serviio-0.6.2 -classpath /usr/local/bin/serviio-0.6.2/lib/*:/usr/local/bin/serviio-0.6.2/config org.serviio.MediaServer
root      2325  0.0  0.0  14820   892 pts/0    S+   21:06   0:00 grep --color=auto serviio
root@poligon:~# stop serviio
serviio stop/waiting
root@poligon:~# ps aux | grep serviio
root      2335  0.0  0.0  14816   892 pts/0    S+   21:06   0:00 grep --color=auto serviio
root@poligon:~# start serviio
serviio start/running, process 2337
root@poligon:~# ps aux | grep serviio
root      2337  0.0  0.0   4392   604 ?        Ss   21:06   0:00 /bin/sh /usr/local/bin/serviio-0.6.2/bin/serviio.sh
root      2342  146  2.0 1213284 42928 ?       Sl   21:06   0:01 java -Xmx384M -Xms20M -XX:+UseParNewGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dderby.system.home=/usr/local/bin/serviio-0.6.2/library -Dserviio.home=/usr/local/bin/serviio-0.6.2 -classpath /usr/local/bin/serviio-0.6.2/lib/*:/usr/local/bin/serviio-0.6.2/config org.serviio.MediaServer
root      2358  0.0  0.0  14816   888 pts/0    S+   21:06   0:00 grep --color=auto serviio
root@poligon:~#


I propose to test my suggestions - I expect the information that helped ;-)
<<

serviio-buddy

User avatar

DLNA master

Posts: 132

Joined: Fri Jan 20, 2012 5:24 pm

Location: United States

Post Fri Mar 23, 2012 8:59 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

Great. I will try your suggestions when I am able to test it on 12.04 Desktop (Precise Pangolin Daily Build)

Thanks again.
serviio-buddy
Beta Tester Group

SONY SMP-N100 Media Player, HP PC: Vista 32/Ubuntu 11.10, Serviio 0.6.2, XBMC, VLC, ASUS eeePC Netbook: Vista 32, XBMC, SHARP Aquos BD-HP25U DLNA Blu-Ray Player

HowTo: Provide supported formats of a device | Record a new ticket on Bitbucket | Provide details of a video file that doesn't play | Turn on detailed logging
<<

Capitrium

Streaming enthusiast

Posts: 20

Joined: Wed Mar 21, 2012 10:17 pm

Post Sat Mar 24, 2012 4:16 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

I came across something interesting which might be relevant. TL;DR version at the bottom of this post.

Let's take a look at the Upstart script posted on the wiki for Ubuntu 11.10:
  Code:
start on started networking
script
   /<path-to-serviio>/serviio.sh
end script
There are two stanzas in this Upstart script: the start stanza and the script stanza. On first glance, it seems simple enough; we start the job specified in the script stanza when the networking job emits a started event, i.e. when networking has started. However, there is one stanza missing from this Upstart script: the expect stanza. Essentially, this tells the Upstart system which PID to look at for a job. This means that the commands
  Code:
sudo start serviio
sudo status serviio
sudo stop serviio
will only work as expected if the Upstart system is aware of which PID corresponds to the 'serviio' job.

Now, when the expect stanza is omiited the Upstart system will track the first PID that it executes in the script stanza. However, most Unix services will daemonize, which means they create a new process (using the fork(2) command) which is a child of the initial process. Additionally, some services will "double fork" to remove any association they may have with the initial process. To allow Upstart to determine the final process ID for a job, it needs to know how many times that process will call fork(2) (side note: there's a pun in there somewhere with processes forking themselves, but I'm too lazy to put any effort into it :)).

Here's where things get interesting:
once a daemon is running, it could then fork a number of "worker" processes which could themselves fork any number of times. Upstart cannot be expected to know which PID is the "master" in this case, considering it does not know if worker processes will be created at all, let alone how many times, or how many times the process will fork initially. As such, it is necessary to tell Upstart which PID is the "master" or parent PID.
Essentially this means we need to know how many times our process forks in order to have an Upstart script work correctly.

So how many times does serviio fork? We can find out with by issuing the command
  Code:
sudo strace -o /tmp/strace.log -fFv <path-to-serviio>/serviio.sh
After allowing a reasonable amount of time for Serviio to start, we kill it and strace with
  Code:
sudo killall -9 strace
To find out how many times our service forked, we use
  Code:
sudo egrep "\<(fork|clone)\>\(" /tmp/strace.log | wc | awk '{print $1}'


TL;DR Version:
When running the above commands, I had interesting results. I ran the above commands twice to find out how many times Serviio was calling fork(2); the first time I got 67, and the second time I got 55. AFAIK, this number should not be larger than 2. Additionally, since we did not specify an expect stanza in out Upstart script, this number should actually not be greater than 0. From this, I can draw two conclusions:
a) Serviio forks itself at least once; the posted Upstart script really shouldn't ever work quite as expected, or at all.
b) Serviio forks itself an undetermined number of times; it either gets stuck in a loop somewhere calling fork(2) over and over, or it creates a bunch of worker processes and I happened to kill strace and serviio before it had created them all which caused the different values (67 vs 55). The posted Upstart script still shouldn't work as expected, or at all.

Of course, I am still a relatively new linux user (I've only been using it for a month or two) so there is also a secret third conclusion:
c) I've spent a good half hour on a wild goose chase since I still have little to no idea as to how anything in linux/ubuntu actually works. But let's pretend it isn't this one ;)

Thoughts?
<<

serviio-buddy

User avatar

DLNA master

Posts: 132

Joined: Fri Jan 20, 2012 5:24 pm

Location: United States

Post Sat Mar 24, 2012 6:40 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

Sounds interesting. I haven't really spent much time with details of the Upstart daemon. Maybe you'll be able to solve this problem trying to get Serviio to automatically run on Ubuntu 11.10 Server (headless) boot.
serviio-buddy
Beta Tester Group

SONY SMP-N100 Media Player, HP PC: Vista 32/Ubuntu 11.10, Serviio 0.6.2, XBMC, VLC, ASUS eeePC Netbook: Vista 32, XBMC, SHARP Aquos BD-HP25U DLNA Blu-Ray Player

HowTo: Provide supported formats of a device | Record a new ticket on Bitbucket | Provide details of a video file that doesn't play | Turn on detailed logging
<<

Capitrium

Streaming enthusiast

Posts: 20

Joined: Wed Mar 21, 2012 10:17 pm

Post Sat Mar 24, 2012 7:05 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

Sounds interesting. I haven't really spent much time with details of the Upstart daemon. Maybe you'll be able to solve this problem trying to get Serviio to automatically run on Ubuntu 11.10 Server (headless) boot.
Well like I said I wouldn't consider myself an experienced linux user, but I can certainly try. Can you run the commands I posted above (and again below):
  Code:
sudo strace -o /tmp/strace.log -fFv <path-to-serviio>/serviio.sh
# Wait a minute or two for the serviio server to start and do some stuff
sudo killall -9 strace
sudo egrep "\<(fork|clone)\>\(" /tmp/strace.log | wc | awk '{print $1}'

and post the results? Try running them more than once and see if you get the same value as well.
<<

serviio-buddy

User avatar

DLNA master

Posts: 132

Joined: Fri Jan 20, 2012 5:24 pm

Location: United States

Post Sat Mar 24, 2012 8:06 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

OK, will try to do this sometime today.

I need to know which version of Serviio are you using 0.6.0.1 or 0.6.2 for the tests you want me to try?

Also, I am very new to using Ubuntu 11.10 Server (headless).
Last edited by serviio-buddy on Sat Mar 24, 2012 8:28 pm, edited 1 time in total.
serviio-buddy
Beta Tester Group

SONY SMP-N100 Media Player, HP PC: Vista 32/Ubuntu 11.10, Serviio 0.6.2, XBMC, VLC, ASUS eeePC Netbook: Vista 32, XBMC, SHARP Aquos BD-HP25U DLNA Blu-Ray Player

HowTo: Provide supported formats of a device | Record a new ticket on Bitbucket | Provide details of a video file that doesn't play | Turn on detailed logging
<<

uid

User avatar

Serviio newbie

Posts: 13

Joined: Thu Mar 22, 2012 8:47 pm

Location: 53°08´56" N 16°42´40" E

Post Sat Mar 24, 2012 8:13 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

serviio-buddy wrote:Maybe you'll be able to solve this problem trying to get Serviio to automatically run on Ubuntu 11.10 Server (headless) boot.

As I wrote above - the topic resolved. Especially I installed Ubuntu Server 11.10 to test my theory. Confirmed. I read about the upstart, and I concluded that this document contains an error. In section 3 it is written:
  Code:
start on started networking
script
   /<path-to-serviio>/serviio.sh
end script

and should be:
  Code:
start on started networking
script
   exec /<path-to-serviio>/serviio.sh
end script

Missing exec command.

My proposal goes beyond that. And works. I will not pollute the forum - interested, I refer to this link. As I wrote earlier - given my example works under Ubuntu 12.04 (development branch - desktop) and at 11.10 server (for example - tested and working).
<<

serviio-buddy

User avatar

DLNA master

Posts: 132

Joined: Fri Jan 20, 2012 5:24 pm

Location: United States

Post Sat Mar 24, 2012 8:54 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

As I wrote above - the topic resolved. Especially I installed Ubuntu Server 11.10 to test my theory. Confirmed.

The users on this thread are all having problems with "Unable to get serviio to run on boot Ubuntu 11.10 Server"

I have tried adding the "exec" to the serviio.conf file as you posted previously, but that doesn't fix it when using Ubuntu 11.10 Server (headless).
Last edited by serviio-buddy on Sat Mar 24, 2012 9:04 pm, edited 1 time in total.
serviio-buddy
Beta Tester Group

SONY SMP-N100 Media Player, HP PC: Vista 32/Ubuntu 11.10, Serviio 0.6.2, XBMC, VLC, ASUS eeePC Netbook: Vista 32, XBMC, SHARP Aquos BD-HP25U DLNA Blu-Ray Player

HowTo: Provide supported formats of a device | Record a new ticket on Bitbucket | Provide details of a video file that doesn't play | Turn on detailed logging
<<

uid

User avatar

Serviio newbie

Posts: 13

Joined: Thu Mar 22, 2012 8:47 pm

Location: 53°08´56" N 16°42´40" E

Post Sat Mar 24, 2012 9:03 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

serviio-buddy wrote:
As I wrote above - the topic resolved. Especially I installed Ubuntu Server 11.10 to test my theory. Confirmed.

I added the "exec" to the serviio.conf file as you posted, but when it boots, serviio is not started.
I am using Ubuntu 11.10 Server with Serviio 0.6.2 and have tried it also with Ubuntu 11.10 Server with Serviio 0.6.0.1 also with the same results.

I'm confused. I gave the information that the 12.04 Desktop (development branch), runs (starts and stops). To make sure I'm right, I installed Ubuntu Server 11.10. I did step by step what I wrote in my case it works. Nothing else will do / has no idea.

SOA #1
<<

serviio-buddy

User avatar

DLNA master

Posts: 132

Joined: Fri Jan 20, 2012 5:24 pm

Location: United States

Post Sat Mar 24, 2012 9:08 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

Unfortunately, your solution to this problem doesn't work for me using Ubuntu 11.10 Server with Serviio 0.6.2.

Does this solve (adding the exec to the serviio.conf file) work for anybody else on this thread?
serviio-buddy
Beta Tester Group

SONY SMP-N100 Media Player, HP PC: Vista 32/Ubuntu 11.10, Serviio 0.6.2, XBMC, VLC, ASUS eeePC Netbook: Vista 32, XBMC, SHARP Aquos BD-HP25U DLNA Blu-Ray Player

HowTo: Provide supported formats of a device | Record a new ticket on Bitbucket | Provide details of a video file that doesn't play | Turn on detailed logging
<<

uid

User avatar

Serviio newbie

Posts: 13

Joined: Thu Mar 22, 2012 8:47 pm

Location: 53°08´56" N 16°42´40" E

Post Sat Mar 24, 2012 9:19 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

serviio-buddy wrote:Unfortunately, your solution to this problem doesn't work for me using Ubuntu 11.10 Server with Serviio 0.6.2.

Does this solve (adding the exec to the serviio.conf file) work for anybody else on this thread?


Well. I'm sorry. I did what I could, specially installed this version (server), I showed that it works. I have nothing else comes to mind.
<<

Capitrium

Streaming enthusiast

Posts: 20

Joined: Wed Mar 21, 2012 10:17 pm

Post Sat Mar 24, 2012 9:45 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

Does this solve (adding the exec to the serviio.conf file) work for anybody else on this thread?
Nope, unfortunately it didn't work for me either.
I need to know which version of Serviio are you using 0.6.0.1 or 0.6.2 for the tests you want me to try?
I currently have Serviio v0.6.2 installed.
Well. I'm sorry. I did what I could, specially installed this version (server), I showed that it works. I have nothing else comes to mind.
Keep in mind that users in this thread (myself included) typically have some kind of issue starting Serviio using any of
  Code:
sudo start serviio
sudo initctl start serviio
etc
but are able to start it (at least in my case) using
  Code:
sudo sh <path-to-serviio>/serviio.sh
Keeping this in mind, maybe you'll get an idea? :)
<<

serviio-buddy

User avatar

DLNA master

Posts: 132

Joined: Fri Jan 20, 2012 5:24 pm

Location: United States

Post Sat Mar 24, 2012 9:55 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

We appreciate any and all input and ideas in helping to fix these type of problems. :)
serviio-buddy
Beta Tester Group

SONY SMP-N100 Media Player, HP PC: Vista 32/Ubuntu 11.10, Serviio 0.6.2, XBMC, VLC, ASUS eeePC Netbook: Vista 32, XBMC, SHARP Aquos BD-HP25U DLNA Blu-Ray Player

HowTo: Provide supported formats of a device | Record a new ticket on Bitbucket | Provide details of a video file that doesn't play | Turn on detailed logging
<<

uid

User avatar

Serviio newbie

Posts: 13

Joined: Thu Mar 22, 2012 8:47 pm

Location: 53°08´56" N 16°42´40" E

Post Sat Mar 24, 2012 11:34 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

Capitrium wrote:but are able to start it (at least in my case) using
  Code:
sudo sh <path-to-serviio>/serviio.sh
Keeping this in mind, maybe you'll get an idea? :)

Please note that the topic concerns the auto-run daemon of serviio ("run on boot Ubuntu server 11.10").

I'm looking also for the reactions of others interested in the subject ;-)
<<

Capitrium

Streaming enthusiast

Posts: 20

Joined: Wed Mar 21, 2012 10:17 pm

Post Sat Mar 24, 2012 11:47 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

Please note that the topic concerns the auto-run daemon of serviio ("run on boot Ubuntu server 11.10").

Correct me if I'm wrong here, but if you can't run serviio as a daemon then you can't auto-run serviio as a daemon, no?
<<

uid

User avatar

Serviio newbie

Posts: 13

Joined: Thu Mar 22, 2012 8:47 pm

Location: 53°08´56" N 16°42´40" E

Post Sun Mar 25, 2012 9:18 am

Re: Unable to get serviio to run on boot Ubuntu server 11.10

Capitrium wrote:
Please note that the topic concerns the auto-run daemon of serviio ("run on boot Ubuntu server 11.10").

Correct me if I'm wrong here, but if you can't run serviio as a daemon then you can't auto-run serviio as a daemon, no?


I wrote and I showed above, that I could and I did so that serviio run during boot and works as a daemon.

P.S.
Look for the reasons proposed in the logs (for me it is: /usr/local/bin/serviio-0.6.2/log/serviio.log).
<<

johnsr11

Streaming enthusiast

Posts: 27

Joined: Thu Mar 01, 2012 11:18 pm

Post Sun Mar 25, 2012 7:24 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

The way that I have fixed it so that serviio is always running, even after you close your shell is that I edited my cron job file for root. Switch to your root user and in the command line type "crontab -e". If an option for how to edit it pops up, select 2 if you have nano, else use what you would like. Once you have the text editor open enter the following " * * * * * /path/to/your/serviio/serviio.sh" where you change this to the path to your serviio.sh and remove the quotation marks. Then you can save the file and exit, and shortly serviio will start and stay running.
<<

serviio-buddy

User avatar

DLNA master

Posts: 132

Joined: Fri Jan 20, 2012 5:24 pm

Location: United States

Post Sun Mar 25, 2012 7:38 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

johnsr11 wrote:The way that I have fixed it so that serviio is always running, even after you close your shell is that I edited my cron job file for root. Switch to your root user and in the command line type "crontab -e". If an option for how to edit it pops up, select 2 if you have nano, else use what you would like. Once you have the text editor open enter the following " * * * * * /path/to/your/serviio/serviio.sh" where you change this to the path to your serviio.sh and remove the quotation marks. Then you can save the file and exit, and shortly serviio will start and stay running.
Will try this fix. Thanks.
serviio-buddy
Beta Tester Group

SONY SMP-N100 Media Player, HP PC: Vista 32/Ubuntu 11.10, Serviio 0.6.2, XBMC, VLC, ASUS eeePC Netbook: Vista 32, XBMC, SHARP Aquos BD-HP25U DLNA Blu-Ray Player

HowTo: Provide supported formats of a device | Record a new ticket on Bitbucket | Provide details of a video file that doesn't play | Turn on detailed logging
<<

Capitrium

Streaming enthusiast

Posts: 20

Joined: Wed Mar 21, 2012 10:17 pm

Post Sun Mar 25, 2012 8:20 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

I have got Serviio v0.6.2 to start at boot! Looks like there were two issues with my Upstart script:
1) The missing expect stanza, as I referenced eariler
2) Use of the tilde (~) character to reference the location of my serviio.sh script. This is not valid, as it references the root users' home directory whereas the script is located in a directory under my user's home directory. Here are the steps I followed to fix the issue.

First, I added the missing expect stanza to the /etc/init/serviio.conf script, above the script stanza. This changed the message I got when trying to start serviio using
  Code:
sudo start serviio
from
  Code:
serviio stop/waiting
to
  Code:
start: Job failed to start
To debug this message, I edited the script stanza of the script to the following:
  Code:
script
    exec 2>>/dev/.initramfs/serviio.log
    set -x
    exec ~/.serviio/bin/serviio.sh
end script

Running the upstart job again from a shell, I opened the /dev/.initramfs/serviio.log file where it told me that the script '~/.serviio/bin/serviio.sh' did not exist. I realized at this point the issue with the ~ character, and changed my Upstart script to the following:
  Code:
start on (started network-interface
          or started network-manager
          or started networking)
expect daemon
script
        exec /home/<username>/.serviio/bin/serviio.sh
end script

Running the upstart job from a shell now gave the expected
  Code:
serviio start/running, process <PID>
message. I rebooted and checked for an instance of the server using
  Code:
ps aux | grep serviio
and saw that the server had indeed started on boot! And I didn't even have to mess around with a cron job, even though that was a clever solution for whoever thought of it.

Let me know if this solution (either the use of the ~ character or the expect stanza) helped anyone with issues getting Serviio v0.6.2 to start on boot on Ubuntu Server 11.10.
<<

serviio-buddy

User avatar

DLNA master

Posts: 132

Joined: Fri Jan 20, 2012 5:24 pm

Location: United States

Post Sun Mar 25, 2012 8:49 pm

Re: Unable to get serviio to run on boot Ubuntu server 11.10

I tried the cron method but ps command did not show it running after reboot.

I will now try your suggestions and give you the results shortly.
serviio-buddy
Beta Tester Group

SONY SMP-N100 Media Player, HP PC: Vista 32/Ubuntu 11.10, Serviio 0.6.2, XBMC, VLC, ASUS eeePC Netbook: Vista 32, XBMC, SHARP Aquos BD-HP25U DLNA Blu-Ray Player

HowTo: Provide supported formats of a device | Record a new ticket on Bitbucket | Provide details of a video file that doesn't play | Turn on detailed logging
PreviousNext

Return to Serviio Support & Help

Who is online

Users browsing this forum: No registered users and 100 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.