How to start GUI application with upstart?

goGud

I have struggled with this problem for three days and I have tried many ways to solve it but not successful yet. I hope you guys can help me...

I have an GUI application. I want to start this application automatically. And when it goes down or closed unexpectedly, I want to reopen this application.

I tried to use upstart script, however although there is no problem about services with upstart, GUI application is not starting with upstart script. It says cannot connect X server.

Should I add or change some settings to open with upstart or is there any way to open GUI application automatically when unexpected exit or shut down occurs (not just once after login I mean not with Startup) ?

Rmano

The problem you are facing is that when upstart (or systemd, or the scripts in /etc/rc.d/) are run, there is normally no graphic service ("the X server") running.

Moreover, the availability of the graphic subsystem in Unix is strictly bond to the concept that a user has done a graphic login, and just this user has the right to use the graphic environment. It is customary NOT to start a graphic subsytem for root --- and the upstart scripts are run by root.

To automatically start a graphic application at the start of the system, my approach would be:

  1. create a user for this purpose. Set it up so that its session will autostart.
    enter image description here

  2. set up a startup application for this user with the program you want; choose "startup application" in the dash: enter image description here

  3. for restarting the application when it exits/crashes, you can simply embed it in a script:

         #!/bin/bash
         #
         while true; do 
              /full/path/to/start_myapp.sh    # NO background (&)!
              # if we land here it exited
              sleep 5
         done
    

If you use this script, it is really important that the command start_myapp.sh should not launch the application in background. Otherwise, more complex strategies are required to auto-restart...

Notice that you can use your normal user in parallel too; just choose "switch user" from the panel (adapt to your flavor of Ubuntu) and you will have another graphical login screen; you can switch back-an-forth using CTRL-ALT-F7 and CTRL-ALT-F8...

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How to create a service on Ubuntu Upstart

분류에서Dev

How to create a service on Ubuntu Upstart

분류에서Dev

How to start an application with bottom most property?

분류에서Dev

How to start an application with bottom most property?

분류에서Dev

How to start an application at boot time or as a service

분류에서Dev

How to start an application Maximized using a .bat file?

분류에서Dev

Upstart 용 GUI 도구가 있습니까?

분류에서Dev

Upstart 스크립트 및 start-stop-daemon

분류에서Dev

Upstart 스크립트 및 start-stop-daemon

분류에서Dev

Run gui application on startup

분류에서Dev

How to read excel file on a Java-Web Start Application

분류에서Dev

"respawning too fast, stopped". How to make UPSTART disable for 5 mins?

분류에서Dev

Heroku Start Failed Application Error

분류에서Dev

How to create a buy application prompt on a certain amount of start-up times

분류에서Dev

Java morse code application continued (gui)

분류에서Dev

What is Upstart?

분류에서Dev

How to open a GUI with PsExec?

분류에서Dev

How to make GUI in DOS?

분류에서Dev

Upstart 작업이`start on runlevel [2345]`를 사용하는 이유는 무엇입니까?

분류에서Dev

How can I check if upstart is installed in ubuntu server and how can I install it?

분류에서Dev

Deploying example Java Web Start application fails .

분류에서Dev

Customized search with application in windows start menu

분류에서Dev

Crontab start node application with forever in production mode

분류에서Dev

Application_Start의 StructureMap IoC

분류에서Dev

How to start xmonad?

분류에서Dev

How to start IntelliJ?

분류에서Dev

How to start a snap package

분류에서Dev

How to start the snapcraft app?

분류에서Dev

Run application on local machine and show GUI on remote display

Related 관련 기사

뜨겁다태그

보관