Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardcoded cache and logs dir paths? #44

Closed
DeviantEng opened this issue Aug 6, 2015 · 4 comments
Closed

Hardcoded cache and logs dir paths? #44

DeviantEng opened this issue Aug 6, 2015 · 4 comments

Comments

@DeviantEng
Copy link

Hello.

I recently came across plexpy, and decided to test it out. I'm especially interested sine it's based on Headphones (I run HP, SAB, SickRage, CP) since I should be able to slap in plexpy next to those other apps, and it be an easy setup. Going through your install, you say to install to /opt which works fine, but I don't like doing that. Essentially, I'm trying to run it on CentOS 7 like this:
/usr/bin/python /apps/plexpy/PlexPy.py --daemon --datadir /apps/data/.plexpy --config /apps/data/.plexpy/plexpy_config.ini --nolaunch --quiet

(That's the ExecStart from my systemd file)
And since I'm running that as plexpy:plexpy, it's failing to start. Why? Because it can't create /opt/plexpy{cache,logs}. If I change my systemd file to run as root:root, it runs. Why? Because root can create those directories in /opt.

Headphones, by default, will put those cache and logs directories, within the data directory. Why doesn't PlexPy?

FWIW, here is a link to my blog post where I document my setup of SAB/SickRage/CouchPotatoServer/Headphones, so you can get a better understanding of how I want to setup PlexPy.

http://deviantengineer.com/2015/06/usenet-centos7/

Thanks!

@drzoidberg33
Copy link
Contributor

Hi @DeviantEng

I haven't tested on Centos 7 but I do have it running like you are asking on my Centos 6.6 box at home. Here the cache and log folders are placed in my specified path.

I've hardly worked at all with systemd so unfortunately cannot give much insight there, but below are examples of my init script and config for reference, might help out.

Here is an example of my config (/etc/sysconfig/plexpy):

# PlexPy service configuration

#run PlexPy as
PP_USER=myuser

PP_HOME=/home/myuser/.python_apps/plexpy

PP_PIDFILE=/var/run/plexpy/plexpy.pid

PP_DATA=/home/myuser/.python_apps/AppData/plexpy

PP_CONFIG=/home/myuser/.python_apps/AppData/plexpy/config.ini

PYTHON_BIN=/usr/local/bin/python2.7

#gui address, eg: ${protocol}://${host}:${port}/plexpy/
protocol=http
host=0.0.0.0
port=8181

#leave blank if no username/password is required to access the gui
username=
password=

#use nice, ionice, taskset to start PlexPy
nicecmd=
#  example: nicecmd="nice -n 19 ionice -c3"

And here is my init script (/etc/init.d/plexpy):

#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          plexpy
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts PlexPy
# Description:       starts PlexPy
### END INIT INFO

# Source function library.
. /etc/init.d/functions

# Source PlexPy configuration
if [ -f /etc/sysconfig/plexpy ]; then
        . /etc/sysconfig/plexpy
fi

prog=plexpy
lockfile=/var/lock/subsys/$prog

## Edit user configuation in /etc/sysconfig/plexpy to change
## the defaults
username=${PP_USER-plexpy}
homedir=${PP_HOME-/opt/plexpy}
datadir=${PP_DATA-/opt/plexpy}
configfile=${PP_CONFIG-/opt/plexpy}
pidfile=${PP_PIDFILE-/var/run/plexpy/plexpy.pid}
nice=${PP_NICE-}
python_bin=${PYTHON_BIN-/usr/local/python}
##

pidpath=`dirname ${pidfile}`
options=" --daemon --quiet --nolaunch --config ${configfile} --pidfile ${pidfile} --datadir ${datadir}"

# create PID directory if not exist and ensure the PlexPy user can write to it
if [ ! -d $pidpath ]; then
        mkdir -p $pidpath
        chown $username $pidpath
fi

if [ ! -d $datadir ]; then
        mkdir -p $datadir
        chown $username $datadir
fi

start() {
        # Start daemon.
        echo -n $"Starting $prog: "
        daemon --user=${username} --pidfile=${pidfile} ${nice} ${python_bin} ${homedir}/PlexPy.py ${options}
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch $lockfile
        return $RETVAL
}


stop() {
        echo -n $"Shutting down $prog: "
        killproc -p ${pidfile} ${python_bin}
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f $lockfile
        return $RETVAL
}

rh_status() {
    # run checks to determine if the service is running or use generic status

    /usr/bin/nc -z $host $port &> /dev/null
    retval=$?

    if [ $retval -eq 0 ];then
        pid=`ps -fu ${username} | grep -v grep | grep PlexPy.py | awk '{print $2}'`
        echo "$prog (pid $pid) is running..."
        return $retval
    else
        echo "$prog is stopped"
        return $retval
    fi

}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
#       status $prog
        rh_status
        ;;
  restart|force-reload)
        stop
        start
        ;;
  try-restart|condrestart)
        if status $prog > /dev/null; then
            stop
            start
        fi
        ;;
  reload)
        exit 3
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
        exit 2
esac

Here is my directory listing to show the folder locations:

[root@home home]# ls -alrt -d -1 /home/myuser/.python_apps/AppData/plexpy/{*,.*}
drwxr-xr-x 6 myuser myuser    4096 Jul 30 12:49 /home/myuser/.python_apps/AppData/plexpy/..
drwxr-xr-x 2 myuser myuser    4096 Jul 30 12:49 /home/myuser/.python_apps/AppData/plexpy/logs
drwxr-xr-x 2 myuser myuser    4096 Jul 30 12:49 /home/myuser/.python_apps/AppData/plexpy/cache
-rw-r--r-- 1 myuser myuser      40 Aug  5 19:12 /home/myuser/.python_apps/AppData/plexpy/version.lock
-rw-r--r-- 1 myuser myuser    4108 Aug  6 07:12 /home/myuser/.python_apps/AppData/plexpy/config.ini
-rw-r--r-- 1 myuser myuser 4519936 Aug  6 07:12 /home/myuser/.python_apps/AppData/plexpy/plexpy.db
drwxr-xr-x 4 myuser myuser    4096 Aug  6 16:12 /home/myuser/.python_apps/AppData/plexpy/.

@DeviantEng
Copy link
Author

Very interesting. Not sure what my issue is then, but I just re-installed in /opt and it's working fine.

So another question, is there a way that I can get the History list outputed to a text file?

@drzoidberg33
Copy link
Contributor

There isn't currently a way to do that.

@drzoidberg33
Copy link
Contributor

I'm closing this as your issue has been resolved.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants