LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 03-02-2014, 03:35 PM   #1
bjdodo
Member
 
Registered: Dec 2006
Location: Ireland
Distribution: Slackware 12, kubuntu
Posts: 35

Rep: Reputation: 16
service application that has access to the GUI


Hi

I have written the app that has a GUI part (it generates images from invisible javafx controls and saves them into images). As a next step I'd like to make it an application that is always running, i.e. something like a service.

I have looked at monit to make it a service, but monit complains:

Failed in XOpenDisplay
(java:4465): Gtk-WARNING **: cannot open display:

Do you have an idea if I can use monit or any similar application to directly run my app?

Features I need:

start my app after reboot
restart my app if it goes down

Any help is appreciated.

Thank you,
Jozsef
 
Old 03-03-2014, 08:09 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Have you tried having the GUI user enabling local access to their X display?
Code:
/usr/bin/xhost +localhost
 
Old 03-03-2014, 04:53 PM   #3
bjdodo
Member
 
Registered: Dec 2006
Location: Ireland
Distribution: Slackware 12, kubuntu
Posts: 35

Original Poster
Rep: Reputation: 16
You have directed me to the right direction (knew what to search for on the internet), thank you for your help.

For beginners like I am:

If you want to run a process from a shell that is not a child process of X, define an environment variable:

export DISPLAY=:0

Maybe you'll need to run the above recommended

/usr/bin/xhost +localhost

and then start your app, and it will find the primary X server (of course X server has to be running for this).

So now to run my app as a service, I run monit from an ordinary user account with the -c switch (how to do it during pc start is the next thing I'll need to look at)
(I need the -c switch so that it uses a config file that I supply rather than the config file in /etc which is set up so that it needs to be run as root because it reads/writes everything in /var)
To run monit as a daemon I do monit -c <conffile> -d 60
And in the startMyApp script I simply added

export DISPLAY=:0
/usr/bin/xhost +localhost

So I can run monit from a shell that is not a child process of X and my app will be able to use the GUI.
 
  


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
[SOLVED] tar - application/service shutdown steinz Linux - Server 3 01-31-2013 11:08 AM
Installing an application using a service account turnec1 Linux - Newbie 1 05-27-2011 05:17 AM
How to start an application/service in startup? lawrence_lee_lee Linux - Software 4 09-21-2007 02:57 AM
how to make an application as a service sharad Linux - General 2 02-26-2007 03:11 AM
How To Program Daemon(Service) Application wlmapp3 Programming 6 07-23-2003 03:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 10:38 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