Hello jim,

Many thanks for chiming in! I copied your example, only close, and then got
an error that I need to provide the complete path for python as well. It
never occured to me as I thought I can invoke Python just from about
everywhere. No way. Now it loads the proper way. Unfortunately my
application still does not start correctly: after importing several other
libraries (like Adafruit) the import of serial (pyserial) goes wrong and
the service halts. I have no idea what goes wrong this time. When I invoke
python from the command line in QTerminal the application starts correctly,
so included the import of serial and other libraries....
Is this a python issue or what?
Maybe time for another topic?
Anyway: Seth and Jim thanks again for your time and effort. Well
appreciated!
Best regards.
Harke


On Mon, 3 Dec 2018 at 17:55, Jim F <[email protected]> wrote:

> Hi Harke,
>
> I am hoping to build up some good will to get an answer to my question, so
> let me see if I can pitch in. Plus I wanted to get a systemd service
> working anyway, which I did successfully this morning. Here are the steps I
> took.
>
> 1) Create the application. I wrote a stupid python program:
>
> #!/bin/env python
> import sys
> print('It ran once.')
> sys.exit(0)
>
> 2) Create the service file
>  - Two ways to do this. First you can create a file in
> /etc/systemd/system/test.service (or whatever name you like) and edit it
> manually. Or you can run systemctl edit --force test.service to do the same
> thing.
>  - The file shall have 644 permissions, root:root owner.
>  - Paste the following simple service file
>
> [Unit]
> Description=Test
>
> [Service]
> ExecStart=/usr/bin/python /home/debian/test.py
>
> [Install]
> WantedBy=multi-user.target
>
> 3. Enable the service file. Run:  systemctl enable test
>   - Response will be:  Created symlink
> /etc/systemd/system/multi-user.target.wants/test.service →
> /etc/systemd/system/test.service.
>
> 4. Check status. Run:  systemctl status test
>   - Response should be:
> ● test.service - Test
>    Loaded: loaded (/etc/systemd/system/test.service; enabled; vendor
> preset: enabled)
>    Active: inactive (dead) since Mon 2018-12-03 14:18:33 UTC; 1s ago
>   Process: 2853 ExecStart=/usr/bin/python /home/debian/test.py
> (code=exited, status=0/SUCCESS)
>  Main PID: 2853 (code=exited, status=0/SUCCESS)
>
> Dec 03 14:18:33 beaglebone systemd[1]: Started Test.
> Dec 03 14:18:33 beaglebone python[2853]: It ran once.
>
>
> 5. Now that you have something stupid working, change the files and
> increase level of complexity. Replace my idiotic test.py program with your
> real one. In editing the service file ensure you use absolute path. Update
> the test.service script and make sure that you run:  systemctl
> daemon-reload   whenever you change the service files.
>
> Hope that helps. It worked for me.
>
> Best,
>
> Jim
>
> On Mon, Dec 3, 2018 at 7:28 AM Harke Smits <[email protected]> wrote:
>
>> Thank you for your support Seth! I do not think I am running anything
>> special. Just one Python script, 400 lines of my code, many thousends in
>> libs, I guess. From QTerminal command line it runs perfectly. From within a
>> service not.
>> Looking at your proposal: do you really intend to write: ExecStart=
>> /path/myprog.py instead of: ExecStart=python /path/myprog.py????
>> That wonders me.
>>  I "sudo nano" the service file and then write it in the
>> /etc/systemd/system/ folder. Nothing else I do.
>> Is that sufficient?
>> Thanks a lot again.
>> Regards,
>> Harke
>>
>>
>>
>>
>> On Mon, 3 Dec 2018 at 05:17, Mala Dies <[email protected]> wrote:
>>
>>> Hello Harke,
>>>
>>> Seth here. Um, are you trying to run a specific piece of software only
>>> or are you trying to run multiple pieces of software?
>>>
>>> Seth
>>>
>>> P.S. I know you have to make a file accessible at
>>> /etc/systemd/system/<your .service file here> w/ the proper instructions in
>>> that .service file. Now, to make it run should be easy, i.e. if this is
>>> just one piece of software.
>>>
>>> [Unit]
>>> Description=More of what will happen!
>>>
>>> [Service]
>>> ExecStart= /your/path/to/the/.py/file.py
>>>
>>> [Install]
>>> WantedBy=multi-user.target
>>>
>>> ^
>>> |
>>> |
>>>
>>> Try this!
>>>
>>>
>>>
>>> On Saturday, December 1, 2018 at 5:48:51 AM UTC-6, Harke Smits wrote:
>>>>
>>>> Hi Seth,
>>>>
>>>> In the meantime I think I tried just about any combination I can think
>>>> of.
>>>> Mostly I get the following error codes after demanding the status;
>>>> Loaded....
>>>> Active: failed
>>>> Process: 1002 ... code = exited, status=203/EXEC
>>>> Main PID: 1002.....
>>>>
>>>> In short; no luck so far........
>>>> I am doing something fundamentally wrong I think... Or it is just
>>>> impossible.
>>>> I am lost here......
>>>> Cheers,
>>>> Harke
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, 30 Nov 2018 at 22:46, Mala Dies <[email protected]> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> When you type under [Service], use only the PATH. Try that idea first.
>>>>> I may be able to help out a bit.
>>>>>
>>>>> Seth
>>>>>
>>>>> P.S. For instance, say I have a Python file in this dir:
>>>>> /home/debian/LoveBone/. I would simply put, under the [Service] tag,
>>>>> ExecStart=/home/debain/LoveBone/MultipleIdeas.py for my PATH. Try that 
>>>>> idea
>>>>> and think about moving that [Unit] option for Requires=graphical.target.
>>>>> Try that section under your [Install] section.
>>>>>
>>>>> On Friday, November 30, 2018 at 10:50:15 AM UTC-6, Harke Smits wrote:
>>>>>>
>>>>>> Hello Seth,
>>>>>>
>>>>>> Thanks a lot for your reaction. I already digested these pages (as
>>>>>> good as I could, I am an RF engineer, not a programmer). Unfortunately 
>>>>>> this
>>>>>> does not help me much. The service file is at the correct location.
>>>>>> I hope to get some clue where I am doing something wrong.
>>>>>> Thanks again, regards,
>>>>>> Harke
>>>>>>
>>>>>>
>>>>>> On Friday, 30 November 2018 12:18:26 UTC+1, Mala Dies wrote:
>>>>>>>
>>>>>>> Hello Again Harke,
>>>>>>>
>>>>>>> Seth here. You need to put your .service files in
>>>>>>> /etc/systemd/system/. I am pretty sure.
>>>>>>>
>>>>>>> Seth
>>>>>>>
>>>>>>> On Monday, November 26, 2018 at 5:49:16 AM UTC-6, Harke Smits wrote:
>>>>>>>>
>>>>>>>> Hello learned group,
>>>>>>>>
>>>>>>>> I have a Python application that I'd like to see start up on boot.
>>>>>>>> It uses Tkinter, so it needs the graphical environment.
>>>>>>>> Running: python /home/debian/eme/myprog.py from the QTerminal
>>>>>>>> command line works as expected. Not outside the LXQT environment, 
>>>>>>>> which is
>>>>>>>> normal I think.
>>>>>>>> I made a service file: myprog.service like this:
>>>>>>>> [Unit]
>>>>>>>> Description=to invoke myprog automatically on boot
>>>>>>>> Requires=graphical.target
>>>>>>>> [Service]
>>>>>>>> Type=simple
>>>>>>>> WorkingDirectory=/home/debian/eme/
>>>>>>>> ExecStart=python /home/debian/eme/myprog.py
>>>>>>>> [Install]
>>>>>>>> WantedBy=multi-user.target
>>>>>>>>
>>>>>>>> Service file is located at both: /etc/systemd/system/ and
>>>>>>>> /lib/systemd/system/ as I am unsure where it actually belongs. Of 
>>>>>>>> course I
>>>>>>>> already spend a lot of time at internet to find a solution. Only succes
>>>>>>>> stories here....
>>>>>>>> I entered the following;
>>>>>>>> sudo systemctl enable myprog.service: nothing special
>>>>>>>> sudo systemctl start myprog.service: service is not loaded
>>>>>>>> properly.....
>>>>>>>> sudo systemctl status myprog.service: error (invalid argument),
>>>>>>>> inactive (dead).
>>>>>>>>
>>>>>>>> Both from bash or within QTerminal: behaviour is the same.
>>>>>>>>
>>>>>>>> Please help me out what to do.
>>>>>>>> Kind regards,
>>>>>>>> Harke
>>>>>>>>
>>>>>>>> --
>>>>> For more options, visit http://beagleboard.org/discuss
>>>>> ---
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "BeagleBoard" group.
>>>>> To unsubscribe from this topic, visit
>>>>> https://groups.google.com/d/topic/beagleboard/goOORlttd2c/unsubscribe.
>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>> [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/beagleboard/91cdcefd-06b6-4d68-96fe-a95b7dcd4573%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/beagleboard/91cdcefd-06b6-4d68-96fe-a95b7dcd4573%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> --
>>> For more options, visit http://beagleboard.org/discuss
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "BeagleBoard" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/beagleboard/goOORlttd2c/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/beagleboard/7ab54d0b-e341-48ff-89d6-d9fac79ec09a%40googlegroups.com
>>> <https://groups.google.com/d/msgid/beagleboard/7ab54d0b-e341-48ff-89d6-d9fac79ec09a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> For more options, visit http://beagleboard.org/discuss
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "BeagleBoard" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/beagleboard/CAHmciaYKU%2BXdLZXAR9gGiJXm2fj9YytG06-AyHX8KZ6fSWgODQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/beagleboard/CAHmciaYKU%2BXdLZXAR9gGiJXm2fj9YytG06-AyHX8KZ6fSWgODQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "BeagleBoard" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/beagleboard/goOORlttd2c/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/CAGS%2B2h_q0FYbebThPZYUhxJWu7d4mFxQOuRM_0-AbCpZhOBcxw%40mail.gmail.com
> <https://groups.google.com/d/msgid/beagleboard/CAGS%2B2h_q0FYbebThPZYUhxJWu7d4mFxQOuRM_0-AbCpZhOBcxw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/CAHmciaamrcbU2hGDMw9WNumkp0sAFBcSFEZ9RnoR22JFuMFSQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to