How do I use pyenv to run Mylar service on boot in Linux?

Information and Tutorials on features in Mylar and how to use it
Post Reply
pgabriel07731
Posts: 3
Joined: Tue May 31, 2016 4:35 pm

How do I use pyenv to run Mylar service on boot in Linux?

Post by pgabriel07731 »

I am very experienced in Windows, but a beginner in Linux (Mint 17 to be specific).

Certain functions of Mylar don't seem to work correctly in these later versions of Mylar. One thing I noticed was that after I add a new series, the picture of the book would never download/display. Just get the little red X as a icon. Also getting a message in the log "Could not get the latest commit from github" after trying to update. This never happened before. So I did a little searching in the forums and found the version of Python makes a big difference. Evilhero had suggested using pyenv so that a specific folder could run a different (newer) version without messing up other apps or Linux in general.

The version of Python that runs globally is 2.7.6. I installed pyenv with two different Python versions to start: 2.7.9 and 3.4.0 and set it up so that the ~/.mylar folder runs 2.7.9. I verified this by running python -V in different folders. All show 2.7.6 as the version except the .mylar folder (shows 2.7.9). Great!

However, when the service starts and I open the web page for it and go to the setting page, it shows Python version at 2.7.6! So at the server, I stop Mylar (sudo service Mylar stop) and start it manually in the ~/.mylar folder (python Mylar.py [with or without -d switch]) when I check at the settings page, it shows Python version 2.7.9! And then adding a series downloads the correct book image and checking for updates! (FYI: I tried 3.4.0 as well, but Mylar didn't run, so I stuck with 2.7.9 for my experimentation.)

But when I reboot the machine, it all goes back to the 2.7.6. I did research and tinkered around with the /etc/init/mylar.conf script (Google to the rescue);

Code: Select all

setuid media
setgid media
start on runlevel [2345]
stop on runlevel [016]
respawn
chdir /home/media/.mylar
exec python Mylar.py -d
Still get the same results whether I add the chdir line or change exec line to exec python /home/media/.mylarMylar.py -d. This tells me it's some sort of environment thing, but not being that familiar with Linux, I can't figure it out (even with Google).

Can one of you Linux gurus help me out? Thanks in advance.

Just to be clear, this is what the setting page shows:
Configuration Options
Mylar Version: development
-- git build 704ef85dec573b90592224243229a6443fec5367.
Python Version : 2.7.6

MYLAR PROGRAM OPTIONS
Mylar Data Directory : /home/media/.mylar
Mylar Program Directory : /home/media/.mylar
Mylar Cache Directory : /home/media/.mylar/cache/
Mylar Config File :/home/media/.mylar/config.ini
User avatar
evilhero
Site Admin
Posts: 2883
Joined: Sat Apr 20, 2013 3:43 pm
Contact:

Re: How do I use pyenv to run Mylar service on boot in Linux

Post by evilhero »

Since I'm a big proponent for pyenv and I run it on my Ubuntu box I should be able to help.

From what I recall you need to specify the path to the python 2.7.9 shim within the service. When you run it from a cli it already knows the path to the required shim, but when you run the service it defaults to the os python path unless specified.

Im on my phone atm, but when I get in front of my box I'll get the path to the shims I'm case you can't locate it.

EDIT:
You probably have to change the last line in your file from:

Code: Select all

exec python Mylar.py -d
to

Code: Select all

<youruser>/.pyenv/versions/2.7.9/bin/python
Note that the <youruser> is where my pyenv branch is installed - by default, pyenv installs into the root of the user directory that installed pyenv and hides it with the '.' preceding the directory .

And Mylar will only work with the 2.7.x branch of python ;)
pgabriel07731
Posts: 3
Joined: Tue May 31, 2016 4:35 pm

Re: How do I use pyenv to run Mylar service on boot in Linux

Post by pgabriel07731 »

Boy, do I feel like a dope! :mrgreen: I tried everything except that and I was beginning to think that pyenv wasn't available to a Linux service at boot time (I'm a Windows guy and Linux newbie).

Is it better to go 2.7.10 (or higher if it exists) or 2.7.9 is fine?

Thank you evilhero & thanks for a great program!
User avatar
evilhero
Site Admin
Posts: 2883
Joined: Sat Apr 20, 2013 3:43 pm
Contact:

Re: How do I use pyenv to run Mylar service on boot in Linux

Post by evilhero »

Some of pyenv isn't very well documented, so it's understandable if things don't work initially.

2.7.9 would be the minimum I would go with (mylar is written on 2.7.9) - but there's no harm in going with 2.7.11. The only occasional problem I've really seen from higher versions is just Incompatibility with specific versions of openssl/pyopenssl which are required for accessing secure sites when searching /downloading
Post Reply