run a python script on startup?

This forum is for Marvell Kirkwood devices such as the GoFlex Home/Net, PogoPlug v1/v2, SheevaPlug, and ZyXEL devices.

run a python script on startup?

Postby gschoppe » Tue Aug 06, 2013 4:19 pm

I have a python script that grabs an input device and parses the signals from it. I need it to run in the background, whenever my pogoplug boots.

I have no idea how to do this in the systemctl environment we're using now.
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm

Re: run a python script on startup?

Postby gschoppe » Tue Aug 06, 2013 5:21 pm

i have almost solved the problem. I created this service file:

$this->bbcode_second_pass_code('', '
[Unit]
After=default.target

[Service]
ExecStart=/usr/bin/python /root/pidora-keyboard.py

[Install]
WantedBy=default.target
')

and run:
$this->bbcode_second_pass_code('', 'systemctl start servicename')

The system loads the script, and I can accurately capture input, as wanted.

However, the terminal never returns to a prompt. It acts like the start process never completes.

If I do a ctrl-z to force quit, it exits, and I continue to capture input as needed, but I'd really like the service to exit properly.
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm

Re: run a python script on startup?

Postby gschoppe » Tue Aug 06, 2013 5:26 pm

oops... spoke too soon... The script persists for a minute or two, after force-quitting the "systemctl start servicename" process, but then it dies. It should persist indefinitely.
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm

Re: run a python script on startup?

Postby grayman4hire » Tue Aug 06, 2013 5:34 pm

Try

$this->bbcode_second_pass_code('', '
[Unit]
After=default.target

[Service]
ExecStart=/usr/bin/python /root/pidora-keyboard.py
RemainAfterExit=yes

[Install]
WantedBy=default.target
')
grayman4hire
 
Posts: 350
Joined: Sat Sep 29, 2012 12:03 am
Location: SF, CA

Re: run a python script on startup?

Postby gschoppe » Tue Aug 06, 2013 5:57 pm

no dice... same behavior.

I have to use ctr-z to end the "systemctl start pidora-keyboard" process, and it then kills the script a few seconds later. I have read elsewhere that this has something to do with python not detaching from the initiating process, but I don't know enough to know if that applies to me, and how.
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm

Re: run a python script on startup?

Postby moonman » Tue Aug 06, 2013 8:57 pm

Yuou didn't specify type. Try oneshot, simple and forking. Also try a bash script that executes the python script if none of the types work. Bash needs to be oneshot
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: run a python script on startup?

Postby wibbel4 » Mon Nov 04, 2013 8:30 pm

Hello moonman,

Thank you for sending me in the correct direction...

$this->bbcode_second_pass_quote('', 'b')y moonman » Tue Aug 06, 2013 8:57 pm

Yuou didn't specify type. Try oneshot, simple and forking. Also try a bash script that executes the python script if none of the types work. Bash needs to be oneshot


I had the same problem. The fix was indeed creating a bash script which executes the python script.. Thanks!
wibbel4
 
Posts: 1
Joined: Mon Nov 04, 2013 8:26 pm


Return to Marvell Kirkwood

Who is online

Users browsing this forum: No registered users and 3 guests