ysbaddaden / prax

Rack proxy server for development
http://ysbaddaden.github.io/prax/
Other
475 stars 49 forks source link

Cannot autostart prax #120

Open thomas-ah opened 9 years ago

thomas-ah commented 9 years ago

Hello ysbaddadan (and any other reader),

I don't know if this is the right place for this kind of issue, but I did not know where to place it elsewhere. If it is misplaced, I sincerely apologize and will close/remove it.

First off, loads of thanks for your hard work! Prax works perfectly on my configuration, a Debian box with LXDE/Openbox as desktop env. and window manager. Really nice application! :)

My issue lies in getting prax to autostart when logging in. According to the LXDE documentation autostarting can be achieved in the same manner as Gnome (or KDA or XFCE or whatever) by adding desktop files to your ~/.config/autostart directory. I have tried adding your example prax.desktop file to this directory, however I changed the exec path to the prax app path (/opt/prax/bin/prax for me) since ~/.local/bin/prax simply does not exist; prax install did not create the folder or the symlink (it did however create the /usr/local/bin/prax symlink). Logging in and out or rebooting does not autostart prax however. Manually creating the bin folder in ~/.local/ and then adding a prax symlink in it pointing to /opt/prax/bin/prax also does not make prax autostart on login-logout or reboot. Adding any other .desktop file here works fine and autostarts that specific application on login.

Alternatively I have tried adding a '@prax start' line to the ~/.config/lxsession/LXDE/autostart file, which did not help. Adding the full path (@/opt/prax/bin/prax start) or the local path ('@~/.local/bin/prax start') to the autostart file also does not work. I also tried this without '@'. Again, autostarting other applications through this manner works fine. The same goes for adding these lines to ~/.config/openbox/autostart, in which case I also tried adding '&' at the end to run the process in the background.

TL;DR: Many many login attempts and reboots later, I can't get prax to autostart. Starting a terminal and simply typing 'prax start' works perfectly. I've been searching for solutions online but cannot seem to find any. I'm at a loss.

Thanks a lot for any attempts to help me end my frustation in advance ;)

ysbaddaden commented 9 years ago

Autostart works differently than starting Prax from a login shell. It will be started directly, not from a login shell where your version manager (rvm, rbenv, etc) has already been configured. Ruby may not be available, or this is the system Ruby, which may be Ruby 1.8 or it doesn't have the rack gem installed —this is the single dependency.

Please configure your version manager as per the wiki page. /opt/prax/bin/prax will always load $HOME/.praxconfig and thus use your configured Ruby environment when starting, whatever where it is started from (shell, autostart, initd, ...).

ysbaddaden commented 9 years ago

You'll may want to debug the problem with /opt/prax/bin/prax start >/tmp/prax.log 2>&1

thomas-ah commented 9 years ago

Hey ysbaddaden,

Thanks for your fast reply and apologies for my slow one.

Immediately after I installed prax I had created ~/.praxconfig to use RVM, so rvm_path should be set nicely, and starting prax from outside of a login shell should have worked to my limited knowledge.

Debugging does not seem to work; running /opt/prax/bin/prax start >/tmp/prax.log 2>&1 outside of a login shell (i.e. using the autostart methods described above) literally does nothing, it seems the command is not ran since no logfile is created. Interesting to note is that autorunning lxterminal -e "/opt/prax/bin/prax start >/tmp/prax.log 2>&1" for example does start a terminal (I can see the window flashing at login), but also does not create a logfile. Directly autostarting the executable (running /opt/prax/libexec/prax-start) through this method makes no difference. Manually running the command from inside a login shell (I'm using lxterminal) still works fine.

I'm currently looking into differences between autostarting and (manually) starting applications from a terminal/shell in Debian to see if I can come up with any factors that might cause this strange behaviour. (Perhaps it has something to do with running applications as root or as a user?)

thomas-ah commented 9 years ago

Small update:

Although I'd rather not, I've resorted to editing system files since nothing else seems to work. Adding the line /opt/prax/bin/prax start > /tmp/prax-rc.log 2>&1 & to /etc/rc.local actually seems to create the logfile. Better yet, the logfile contains a hopeful message: Starting prax in the background. Disappointingly enough, prax is not running in the background at all...

Moving onward to other solutions :)

ysbaddaden commented 9 years ago

You'll may want to wrap it in a simple shell script (just not a login shell) so the redirections will be processed, and also export PRAX_DEBUG and use the --foreground flag:

#! /bin/sh
export PRAX_DEBUG=1
/opt/prax/bin/prax start --foreground > /tmp/prax.log 2>&1

Running prax as root will indeed not work, because it would then try to read /root/.praxconfig (and certainly fail) instead of /home/<user>/.praxconfig

ysbaddaden commented 9 years ago

BTW: don't run libexec/prax-start directly because it would be missing some ENV variables set by bin/prax.