Jump to content

Double emby process


ytzelf
Go to solution Solved by gsnerf,

Recommended Posts

ytzelf

Hello everyone,

 

I seem to have 2 emby processes running, one is running as root (dont want) with the correct MONO_THREADS_PER_CPU and MONO_GC_PARAMS arguments, and one running as emby user (all good) without these arguments.

 

ps auxZ | grep emby

root       784  0.0  0.0  46360  3224 ?        Ss   12:59   0:00 su -s /bin/sh -c exec "$0" "$@" emby -- env MONO_THREADS_PER_CPU=250 MONO_GC_PARAMS=nursery-size=128m /usr/bin/mono-sgen --optimize=all /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe -programdata /var/lib/emby-server -ffmpeg /usr/bin/ffmpeg -ffprobe /usr/bin/ffprobe -restartpath /usr/lib/emby-server/restart.sh

emby       894  2.5  4.5 1452236 370664 ?      Ssl  12:59   1:43 /usr/bin/mono-sgen --optimize=all /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe -programdata /var/lib/emby-server -ffmpeg /usr/bin/ffmpeg -ffprobe /usr/bin/ffprobe -restartpath /usr/lib/emby-server/restart.sh

Is having 2 processes normal? why is one running as root?

 

And lastly, how do I fix this if it is indeed abnormal? How do I get 1 process with the cirrect arguments running as emby user?

 

nano /etc/systemd/system/multi-user.target.wants/emby-server.service

[Unit]Description=Emby Media Server
After=network.target


[Service]
EnvironmentFile=/etc/emby-server.conf
ExecStart=/usr/bin/emby-server start
Restart=on-abort
TimeoutSec=20
ExecStopPost=/usr/bin/emby-server clear


[Install]
WantedBy=multi-user.target

nano /etc/init.d/emby-server

!/bin/sh### BEGIN INIT INFO
# Provides:          emby-server
# Required-Start:    $remote_fs $local_fs $network
# Required-Stop:     $remote_fs $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts instance of Emby
# Description:       starts instance of Emby
### END INIT INFO




# chkconfig: 2345 20 80
#The above indicates that the script should be started in levels 2, 3, 4, and 5, #that its start priority should be $
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh


# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions


NAME=emby-server
CONF_FILE=/etc/${NAME}.conf
DEFAULT_FILE=/etc/default/${NAME}


# Source Emby server default configuration
. $DEFAULT_FILE


# Source Emby server user configuration overrides
if [ -f $CONF_FILE ]; then
  . $CONF_FILE
else
  echo "${CONF_FILE} not found using default settings.";
fi


# Path of emby binary
EMBYSERVER=/usr/bin/emby-server
PIDFILE=${EMBY_PIDFILE-/var/run/emby-server.pid}


case "$1" in
  start)
    log_daemon_msg "Starting $NAME daemon"
    if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then
      log_daemon_msg "apparently already running"
      log_end_msg 0
      exit 0
    fi
    exec $EMBYSERVER start &
    sleep 2
    if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then
      log_end_msg 0
    else
      log_end_msg 1
    fi
  stop)
    log_daemon_msg "Stopping $NAME daemon"
    if [ ! -s $PIDFILE ] || ! kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then
      [ -e $PIDFILE ] && rm -rf $PIDFILE
      log_success_msg "apparently already stopped"
      log_end_msg 0
      exit 0
    fi
    PID=`cat $PIDFILE`
    CPIDS=$(pgrep -P $PID)
    sleep 2 && kill -KILL $CPIDS
    kill -TERM $CPIDS > /dev/null 2>&1
    sleep 2
    if ! kill -0 $PID > /dev/null 2>&1; then
      rm -rf $PIDFILE
      log_end_msg 0
    else
      log_end_msg 1
    fi
    ;;
  status)
    status_of_proc -p $PIDFILE "$EMBYSERVER" "$NAME"
    exit $? # notreached due to set -e
    ;;
  restart|force-reload)
    $0 stop || exit $?
    $0 start || exit $?
    ;;
  *)
    echo "Usage: /etc/init.d/emby-server {start|stop|status|restart|force-reload}" >&2
    exit 3
    ;;
esac

Thanks :)

Edited by ytzelf
Link to comment
Share on other sites

Hi, great investigation although unforuntatley I'm not sure. i haven't heard of this happening before.  there should never be one running as root. i would just shut that one down.

Link to comment
Share on other sites

ytzelf

Thanks but I can't be bothered to shut it down everytime i reboot the server.

Is it normal to have both an init.d script and a .service file? thought the error might come from me having both..

 

Is there a way to check what launched the root user process at startup?

Link to comment
Share on other sites

gsnerf

Hi,

 

having scripts for different init systems installed at the same time shouldn't be a problem as long as there is only one init system active. I'd say this is the usual case (I'm not even sure if multiple init systems CAN be active at the same time).

 

What output does

ps auxf

 give you? This should print a tree for child processes of the actual process. On a quick glimpse I see a restart script incorporated, maybe a restart is tried and somehow doesn't finish the original process while doing so?

I'll have a deeper look when I get home but it would help to know which script is actually started.

 

Additionally: which linux distribution do you have this running on and how have you installed it? (premade package or setup manually?)

Link to comment
Share on other sites

ytzelf

hello and thanks for your help!

 

ps auxf

root     18702  0.0  0.0  46360  3028 ?        Ss   10:28   0:00 su -s /bin/sh -c exec "$0" "$@" emby -- env MONO_THREADS_PER_CPU=250 MONO_GC_PARAMS=nursery-size=128m /usr/bin/mono-sgen --optimize=all /usr/lib/emby-server/bin/MediaBrowse
emby     18713  3.6  5.7 1552548 467064 ?      Ssl  10:28   9:39  \_ /usr/bin/mono-sgen --optimize=all /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe -programdata /var/lib/emby-server -ffmpeg /usr/bin/ffmpeg YADA YADA

The non root process is child to the root process

 

I don' think restart script is in cause as number of processes never exceed 2

 

May also be useful

 

service emby-server status -l

● emby-server.service - Emby Media Server
   Loaded: loaded (/lib/systemd/system/emby-server.service; disabled)
   Active: active (running) since Wed 2016-06-29 10:28:58 CEST; 4h 29min ago
  Process: 18603 ExecStopPost=/usr/bin/emby-server clear (code=exited, status=0/SUCCESS)
 Main PID: 18702 (su)
   CGroup: /system.slice/emby-server.service
           ├─18702 su -s /bin/sh -c exec "$0" "$@" emby -- env MONO_THREADS_PER_CPU=250 MONO_GC_PARAMS=nursery-size=128m /usr/bin/mono-sgen --optimize=all /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe -programdata /var/lib/emb...
           └─18713 /usr/bin/mono-sgen --optimize=all /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe -programdata /var/lib/emby-server -ffmpeg /usr/bin/ffmpeg -ffprobe /usr/bin/ffprobe -restartpath /usr/lib/emby-server/restart.s...


Jun 29 10:28:58 ytzelf su[18702]: Successful su for emby by root
Jun 29 10:28:58 ytzelf su[18702]: + ??? root:emby
Jun 29 10:28:58 ytzelf su[18702]: pam_unix(su:session): session opened for user emby by (uid=0)

I'm running emby-server-beta on debian 8 and installed following the process here : https://software.opensuse.org/download.html?project=home%3Aemby&package=emby-server-beta

Edited by ytzelf
Link to comment
Share on other sites

  • Solution
gsnerf

As far as I can see the first process is the start script (/usr/bin/emby-server) propably running as root as it is started by the systemd init script. That process is using su to change the user to emby and start the actual emby process.

So emby-server is actually running as user emby, only the spawning process (which does nothing but wait that emby is stopping) is running as root.

 

There propably is a way to change how the process is started, but I don't think you have to worry about emby itself running as the wrong user.

  • Like 2
Link to comment
Share on other sites

As far as I can see the first process is the start script (/usr/bin/emby-server) propably running as root as it is started by the systemd init script. That process is using su to change the user to emby and start the actual emby process.

So emby-server is actually running as user emby, only the spawning process (which does nothing but wait that emby is stopping) is running as root.

 

There propably is a way to change how the process is started, but I don't think you have to worry about emby itself running as the wrong user.

This is correct.

 

Nothing to worry about. Emby process is only spawn once.

 

 

Sent from my iPhone using Tapatalk

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...