This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/PROCESSOR-SDK-AM57X: Starting two processes at boot time

Part Number: PROCESSOR-SDK-AM57X

Tool/software: Linux

Hello, I have two programs that communicate to each other using a Unix domain socket, one as a server, the other as a client, and I'd like to have them come up with each boot.  The server program is a Qt application, and runs when Weston/Wayland is available.  The other is a Python script with no graphical elements.  How I bring the two programs up now, is to open the Qt application, which waits at a blocking listen() call for the Python script to connect over Unix domain socket.  Then I run the script, it connects, and the GUI is available.  I'd like this to be performed at boot, but I'm unsure how to do it.

How can I make it such that my Qt app is launched after Weston launches, then the python script after that?  I've looked into systemd services, however I cannot seem to make the Qt app actually launch after weston is available.  These two processes (Qt and Python) should be the last two processes in the startup sequence

Thanks.

  • Hello Tom,

    Create these two SystemD services and one Bash helper script to export the /etc/profile.d/wayland_env.sh.

    /lib/systemd/system/qtapplication.service

    [Unit]
    Description=Qt Application Service
    After=weston.service
    
    [Service]
    Type=idle
    ExecStart=/home/root/qtapplication.sh
    StandardOutput=journal+console
    
    [Install]
    WantedBy=multi-user.target


    /lib/systemd/system/pythonscript.service

    [Unit]
    Description=Python Script Service
    After=qtapplication.service
    
    [Service]
    Type=idle
    ExecStart=/usr/bin/python /home/root/pythonscript.py
    StandardOutput=journal+console
    
    [Install]
    WantedBy=multi-user.target


    /home/root/qtapplication.sh

    #!/bin/sh
    . /etc/profile.d/wayland_env.sh
    /home/root/yourqtapplication

    Define the proper permissions and enable the services.

    chmod 644 /lib/systemd/system/qtapplication.service
    chmod 644 /lib/systemd/system/pythonscript.service
    chmod 755 /home/root/qtapplication.sh
    chmod 755 /home/root/pythonscript.py
    chmod 755 /home/root/yourqtapplication
    systemctl enable qtapplication.service
    systemctl enable pythonscript.service
    systemctl daemon-reload


    For further tune-ups, please refer to SysmtemD manual page.
    www.freedesktop.org/.../systemd.service.html

    Best regards,
    Kemal

  • Kamal, you're a genius. Thank you very much! I didn't know about the wayland_env.sh file, and I was getting errors about XDG_RUNTIME_DIR, and it was driving me crazy.