LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-02-2009, 05:03 AM   #1
VectorThorn
LQ Newbie
 
Registered: Nov 2006
Location: Hell's Gate
Distribution: Fc10
Posts: 19

Rep: Reputation: 0
Unhappy xorg, Xvfb, ImageMagick


Hi guys, i've been stuck on this for a while now, and will not repost my findings at http://forums.fedoraforum.org/showthread.php?p=1299875 in this forum, as i am past most of it now.


Here's where i'm still stuck: if i use any combination of this command from the cli, it is fine, but when executing it from apache, it doesn't work. I don't even get any errors for it any more (i got past most of that), but it just isn't working when executed with php/apache... The problem is that i can't find a way to execute ALL commands in the SAME Xvfb instance. It tries to open a new instance for each separate command passed to it. And this is the GOOD side; that is when i'm running it from the cli (local or live, doesn't matter); i can get it to work, for crap, from apache............


Code:
#!/bin/bash
export DISPLAY=:66 <---this isn't necessary, but is only a hack that i was playing with.
xvfb-run -a firefox http://example.com &
sleep 3;
xvfb-run -a import -window root /home/ionisis/public_html/TEMP/x.png
Anyone know how to get this working on a headless production server???

Thanx
 
Old 12-02-2009, 11:31 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
It isn't entirely clear to me from your posting in either forum exactly what your objective is. It looks like you simply want to use Xvfb as your X server on a headless machine. I do this all the time, by simply launching a perpetual Xvfb, as server 1, and then set $DISPLAY=localhost:1 for all subsequent X clients that need to use the virtual X server. I don't have any xvfb-run on any system I presently have access to; I simply have in rc.local
Code:
su -c "Xvfb :1 -auth /etc/Xvfb.auth -f /tmp" xvfbuser &
In this example, 'xvfbuser' is a special user ID created simply to run xvfb. /ect/Xvfb.auth simply contains one line with the word 'localhost'.
I only ever use xterms on my virtual X servers, so I'm not sure what problems might crop up for other applications. When using Mozilla web browsers, it might be important to launch them with the -no-remote option, so they don't try to latch on to a pre-existing instance with the [annoying] x-remote feature.

--- rod.

Last edited by theNbomr; 12-02-2009 at 11:33 AM.
 
1 members found this post helpful.
Old 12-02-2009, 02:18 PM   #3
VectorThorn
LQ Newbie
 
Registered: Nov 2006
Location: Hell's Gate
Distribution: Fc10
Posts: 19

Original Poster
Rep: Reputation: 0
Well, you're close.

I'm launching it with apache, by hitting a php test page on ionisis.com, and that php page calls the exec command which is supposed to launch a virtual x (Xvfb), and then a firefox instance, and sleeps for 4 seconds, and then uses import to grab a screenshot of the website. I've got this all in a shell script, and if i exec the shell script from the console, as a USER (me, or root), on my machine OR my server, all is fine; but when i have APACHE exec it via php "exec", i keep running into various problems.

I've got ALMOST all of it sorted out right now . I had to create a /var/www/.gnome/ and a /var/www/.gnome_private/ and a /var/www/.gnome/accels directory that eliminated a LOT of errors, and now i actually get a screenshot from it when using apache! However it is an EMPTY X screen, with the old-school cross hatch background, and no firefox or import. Like i said, i've tracked down a lot of the errors, and eliminated them. Here are the latest errors (in total):

Code:
[^v^] cat /var/log/httpd/error_log | tail 
xauth:  creating new authority file /tmp/xvfb_1_at_a_time
_XSERVTransmkdir: ERROR: (l)stat failed for /tmp/.X11-unix (13)
_XSERVTransSocketUNIXCreateListener: mkdir(/tmp/.X11-unix) failed, errno = 13
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for unix
Xlib:  extension "RANDR" missing on display ":66.0".
firefox: no process killed
I'm not sure why it's trying to create that directory when it is already there; furthermore, why it is trying to create it when run by APACHE, but not when run by a USER...

Thanx!

Last edited by VectorThorn; 12-02-2009 at 03:06 PM.
 
Old 12-02-2009, 04:28 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Okay, now I get it. Is there any reason not to launch the virtual X server once only, and leave it running? You can have the first invocation start it up, and then simply test for existence of it on subsequent invocations. Also, from my experience, if the virtual X server uses a font server, especially a remote font server, it takes a finite time to initialize the fonts. I put a 3 second sleep between starting Xvfb and running any X client that would use it. Perhaps Apache + PHP is slower to load Xvfb, and you require more than 4 seconds to complete. Have you tried launching something smaller/faster than Firefox, at least as a test?
I'm not extremely familiar with Apache configuration, but as I recall, there are several config items that limit Apache's use of the filesystem. Also, there is the favorite old water hazard called Selinux, which always seems to be particularly entertaining in how it interacts with Apache. The error messages you posted make me think that Xvfb is inheriting some of these restrictions, as a child process of Apache.

--- rod.
 
Old 12-02-2009, 04:38 PM   #5
VectorThorn
LQ Newbie
 
Registered: Nov 2006
Location: Hell's Gate
Distribution: Fc10
Posts: 19

Original Poster
Rep: Reputation: 0
Well, believe it or not, i'm actually very good about configuring servers to work WITH SELinux (see Linux Intro articles on Samba, FTP, and Webservers), and i'm not getting any SEL context error or Permission Denied errors (i was getting pm denied before, but i fixed it). Also, apache IS creating the thumbnail, but again, it is only an exmpty x background; so it IS writing to the fs just fine, afaik.

I am open to keeping Xvfb running, but not firefox. I have to pay for memory on my dedicated servers, and so if something takes to much memory, guess which process is the first to fail: named!!!!!! So i try to be very cautious about memory. As far as *lighter* browsers, i'm open to suggestions as well, ESPECIALLY if they DO NOT have that damned session restore feature !

I am not using "sleep 4" until AFTER i launch firefox, which works fine in user mode, but not apache mode. I do not use it at all between the launch of Xvfb and firefox; i will try it and see if it helps.

So, with a persistent Xvfb instance, do you think that perhaps i could launch it as a USER, and then USE it from APACHE?

Thanx
 
Old 12-02-2009, 06:03 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by VectorThorn View Post
Well, believe it or not, i'm actually very good about configuring servers to work WITH SELinux (see Linux Intro articles on Samba, FTP, and Webservers), and i'm not getting any SEL context error or Permission Denied errors (i was getting pm denied before, but i fixed it). Also, apache IS creating the thumbnail, but again, it is only an exmpty x background; so it IS writing to the fs just fine, afaik.
Yes, the X image file is getting created, but that business about the authority file is a concern. I don't know why it looks like it is trying to create a new one. It might be trying to adjust some permissions. I think Xvfb is fussy about having that set right. Have you tried creating one, and then specifying to Xvfb that it should use it?
Also, the business of
Code:
Xlib:  extension "RANDR" missing on display ":66.0".
The way Xvfb finds extensions (RANDR, whatever that is), must derive from environment variables ($PATH, $LD_LIBRARY_PATH) That would explain why no such complaint exists when run not as a child of Apache.
Quote:
I am open to keeping Xvfb running, but not firefox.
Yea, I hear you there.
Quote:
I am not using "sleep 4" until AFTER i launch firefox, which works fine in user mode, but not apache mode. I do not use it at all between the launch of Xvfb and firefox; i will try it and see if it helps.
So, how does firefox know when to quit? I assume you must kill it. If so, how do you know that it has loaded, rendered, attached to the specified web server, downloaded the page, and then rendered that? I'm thinking 4 seconds may not be enough. Plus, by the way I read your initial sample code, it looks like you are using X to run firefox (the mysterious 'xvfb-run'), which is going to be another slow part of the overall chain.
I am curious how you look after all of the processes that seem to be getting launched. That is part of my rationale behind reducing the chain of processes.
Quote:
So, with a persistent Xvfb instance, do you think that perhaps i could launch it as a USER, and then USE it from APACHE?
Yes, that is essentially what I do. I use an X authorization file that allows anything on localhost to attach to the server. Someone 'skilled in the art' should be able to refine this significantly.
Sounds like a fun project you've got cooking, there.

--- rod.
 
Old 12-06-2009, 11:44 PM   #7
VectorThorn
LQ Newbie
 
Registered: Nov 2006
Location: Hell's Gate
Distribution: Fc10
Posts: 19

Original Poster
Rep: Reputation: 0
Hmm, i don't know why i'm not getting my reply notifications, it is set for instant notification...

Quote:
Originally Posted by theNbomr View Post
Yes, the X image file is getting created, but that business about the authority file is a concern. I don't know why it looks like it is trying to create a new one. It might be trying to adjust some permissions. I think Xvfb is fussy about having that set right. Have you tried creating one, and then specifying to Xvfb that it should use it?
Yeah, i tried that in /var/www and in /etc/httpd and neither one worked...

Quote:
Originally Posted by theNbomr View Post
Also, the business of
Code:
Xlib:  extension "RANDR" missing on display ":66.0".
The way Xvfb finds extensions (RANDR, whatever that is), must derive from environment variables ($PATH, $LD_LIBRARY_PATH) That would explain why no such complaint exists when run not as a child of Apache.
Actually, i DO get that for users as well; but you still have a good point.

Quote:
Originally Posted by theNbomr View Post
So, how does firefox know when to quit? I assume you must kill it. If so, how do you know that it has loaded, rendered, attached to the specified web server, downloaded the page, and then rendered that? I'm thinking 4 seconds may not be enough. Plus, by the way I read your initial sample code, it looks like you are using X to run firefox (the mysterious 'xvfb-run'), which is going to be another slow part of the overall chain.
I am curious how you look after all of the processes that seem to be getting launched. That is part of my rationale behind reducing the chain of processes.
Well, i kill it after i give the order for the screenshot to be taken. It all works flawlessly when run as a user, but not for apache.

Quote:
Originally Posted by theNbomr View Post
Yes, that is essentially what I do. I use an X authorization file that allows anything on localhost to attach to the server. Someone 'skilled in the art' should be able to refine this significantly.Sounds like a fun project you've got cooking, there.
I will have to give that a shot (don't know when i will get time now, as i've moved on to another project for a while...), thanks for the tip!
 
Old 12-07-2009, 03:39 AM   #8
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Rep: Reputation: 57
Quote:
Originally Posted by VectorThorn View Post
Hi guys, i've been stuck on this for a while now, and will not repost my findings at http://forums.fedoraforum.org/showthread.php?p=1299875 in this forum, as i am past most of it now.


Here's where i'm still stuck: if i use any combination of this command from the cli, it is fine, but when executing it from apache, it doesn't work. I don't even get any errors for it any more (i got past most of that), but it just isn't working when executed with php/apache... The problem is that i can't find a way to execute ALL commands in the SAME Xvfb instance. It tries to open a new instance for each separate command passed to it. And this is the GOOD side; that is when i'm running it from the cli (local or live, doesn't matter); i can get it to work, for crap, from apache............


Code:
#!/bin/bash
export DISPLAY=:66 <---this isn't necessary, but is only a hack that i was playing with.
xvfb-run -a firefox http://example.com &
sleep 3;
xvfb-run -a import -window root /home/ionisis/public_html/TEMP/x.png
Anyone know how to get this working on a headless production server???

Thanx
I used this way:
Code:
#!/bin/sh


killall -e skype

killall -e skype Xvfb

 Xvfb :2 &

 DISPLAY=:2 ; export DISPLAY ; skype &

 scrot -c -d 3 importscreenshot.jpg
then to see the screen:
I use scrot
Code:
scrot -c -d 3 importscreenshot.jpg
it works
 
Old 12-07-2009, 02:38 PM   #9
VectorThorn
LQ Newbie
 
Registered: Nov 2006
Location: Hell's Gate
Distribution: Fc10
Posts: 19

Original Poster
Rep: Reputation: 0
Ok, but you're running that as a USER, or as APACHE?

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
install ImageMagick-6.5.1-2 & ImageMagick-devel-6.5.1.2 in red hat mokkai Linux - Enterprise 4 04-16-2009 12:04 PM
Xvfb question ndo Linux - General 1 05-18-2007 10:49 AM
Xvfb and gnome dogalmity Linux - General 0 07-26-2006 10:23 AM
xvfb issues asyoung Linux - General 0 07-14-2003 11:49 AM
Xvfb listening to all IP addresses? ericcarlson Linux - General 0 09-10-2002 05:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration