richibrics / IoTuring

Your Windows, Linux, macOS computer as MQTT and HomeAssistant integration
https://pypi.org/project/IoTuring/
GNU General Public License v3.0
70 stars 6 forks source link

Autostart script enable/disable #39

Open richibrics opened 1 year ago

richibrics commented 1 year ago

I think the script autostart at boot is a must have feature.

Need "autostarter" developer to accept my PR.

infeeeee commented 1 year ago

There are a some problems in that module for Windows and Linux:

Maybe I will create a PR for fixing the linux features, as I need that.

richibrics commented 1 year ago

Yes I saw that there are some problems so I was building something similar on my own (look at runonboot repo). I have to add Linux and Windows (this one is the next I do).

richibrics commented 10 months ago

Needs RunOnBoot completion

infeeeee commented 10 months ago

Related: I documented here how I run IoTuring with systemd in a venv: https://github.com/infeeeee/IoTuring/blob/autostart/docs/Tips.md#run-as-a-service-on-linux-with-systemd

richibrics commented 10 months ago

Really nice, thank you

warmfire540 commented 9 months ago

in Windows just make a startup task to run py -m IoTuring

infeeeee commented 9 months ago

in Windows just make a startup task to run py -m IoTuring

What if you want to run it as a service? Ideally you want to restart IoTuring automatically if it stops. What if you installed with pipx? What if you downloaded a prebuilt executable (will be available in the future, I started working on it). There are even multiple startup folders one for admin and one per regular user. You cannot be sure if a task is run successfully, and it won't restart. You can also start scripts with group policy, so you can autostart on all of your computers in your domain, maybe it's a better option for some users.

A lot of things can go wrong, and there are a lot of ways you can start a program automatically on windows. There is a reason this was not implemented yet in this project.

But I think IoTuring should run as a service, regardless of platform, that's what a service was meant for, not as a task.

For manually creating services on windows my favorite tool is NSSM: https://nssm.cc/download Services can restart automatically, can start before a user logs on, and you have much more options. But I think we should look for some command line options instead of NSSM, windows has some tools for that, I used it a long time ago.

warmfire540 commented 9 months ago

@infeeeee are you using a local user to run the service? not sure it's able to run as local system, I was having that issue when using Tasks as well.

My only account doesn't have a local pw (MS acct) - I'll make a user if needed, just want to avoid extra tid bits if not needed. Here is my command

nssm.exe install IoTuring-Integration "C:\Users\userAcct\AppData\Local\Programs\Python\Launcher\py.exe" "-m IoTuring"

infeeeee commented 9 months ago

@warmfire540 Currently I don't yet run this project as a service on windows, but I played with these things a lot some time ago on other projects.

warmfire540 commented 9 months ago

OK I finally got this working - thanks all for the help!

infeeeee commented 9 months ago

@warmfire540 Can you write down what you did? Maybe it would helps others in the future. Thanks!