0

I have a worker that is running in a non-interactive shell. The worker is needing to open up a chrome browser to do scraping, but we are getting a chrome not reachable error due to the worker not having access to the display. (same scripts work when using interactive shell)

How would I give this non-interactive shell worker access to the display in the .bashrc file?

xslibx
  • 101
  • @pa4080 Just gave it a shot, but no luck. – xslibx Dec 16 '22 at 17:52
  • "non-interactive" has nothing to do with X access. DISPLAY is an environment variable, so gets inherited from everything you spawn. If this "worker" is from somewhere else, did you set the xhost permissions to allow access? – ubfan1 Dec 16 '22 at 18:09
  • Why would you do this using chrome? Can't you use a text-based browser? This feels like an XY problem. It might make more sense to ask a question where you explain what you are trying to do, what the final objective is, because the idea of using something as resource-hungry and complex as chrome in a shell script really seems strange. And interactive vs non-interactive shouldn't make any difference. Are you sure both shells are bash? Isn't one actually sh? Does running xhost + help? – terdon Dec 16 '22 at 18:50
  • @ubfan1 @terdon Sorry I'm quite new with ubuntu. I'm a php developer. We have a Laravel project hosted on an ubuntu server. There are daemon workers that are running jobs that are scrapping websites using a headful chrome browser (headless selenium has issues, so needs to be headful which is why we are using an ubuntu vm as our server). I can run the same job/scraper from my interactive terminal, but if I run it as a worker, which uses a non interactive shell, chrome does not start. I had to run xhost +local: to get the interactive terminal to work. – xslibx Dec 16 '22 at 20:30

0 Answers0