PDA

View Full Version : How to start an application automatically without login. App should start with OS




danje
Mar 24, 2013, 10:00 AM
Hi all,

I use ServeToMe as a streaming server with my Mac.

The tool works very fine.

But I would like to start the application automatically with the system. So ServeToMe can start without manually launch it or start automatically with a login.

A try to create a .plist file under /Library/LaunchDaemons


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ServeToMe</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/ServeToMe.app/Contents/MacOS/ServeToMe</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>



But it seems that ServeToMe is not started as I can't connect to the server using StreamToMe.

Do you have a solution for me?

Regards



justperry
Mar 24, 2013, 10:09 AM
Hi all,

I use ServeToMe as a streaming server with my Mac.

The tool works very fine.

But I would like to start the application automatically with the system. So ServeToMe can start without manually launch it or start automatically with a login.

A try to create a .plist file under /Library/LaunchDaemons


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ServeToMe</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/ServeToMe.app/Contents/MacOS/ServeToMe</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>



But it seems that ServeToMe is not started as I can't connect to the server using StreamToMe.

Do you have a solution for me?

Regards

I am pretty sure it must be in Alphabetical order, screenshots to show you the difference of two .plist files.

One is yours and one is a working from LittleSnitch

danje
Mar 24, 2013, 10:37 AM
Thanks for your answer.

But I think it's not the good way.
As when I try to start the plist manually using

launchctl load -w /Library/LaunchDaemons/ServeToMe.plist

ServeToMe start as the GUI is displayed and when I try to close the app, it is restarted automatically as I've specified in my .plist file

However when I restart my macOS, it seems not working :'(

I'll try to modify my .plist with your order

justperry
Mar 24, 2013, 10:49 AM
Thanks for your answer.

But I think it's not the good way.
As when I try to start the plist manually using

launchctl load -w /Library/LaunchDaemons/ServeToMe.plist

ServeToMe start as the GUI is displayed and when I try to close the app, it is restarted automatically as I've specified in my .plist file

However when I restart my macOS, it seems not working :'(

I'll try to modify my .plist with your order

As I said before, I am almost 100% sure it needs to be in alphabetical order.
Also, How did you make the plist, did you use a regular text editor, I have Developer tools installed and that what I use, but you can also use a text editor and then copy and paste it in an HexEditor and than safe the file as a plist file, something which also might affect it is permissions, you might set the permissions to ones similar in the Folder you place it in.
Another thing is, do you place it in the LaunchAgents or LaunchDeamons, if it does not work in the first one place it in the other one, it might just be you placed it in the wrong Launch.... Folder.

Edit: If you read the System Log while it is not loaded you might find out why it didn't, believe me, if it doesn't it will say so in the System Log.

danje
Mar 24, 2013, 11:01 AM
I made tests in both Folder LaunchAgents and LaunchDaemons.

I made a chmod 644 on the file.

I don't use developer tool for a such file. I'll try to find it for free.

I'll make the test with your order now.

justperry
Mar 24, 2013, 11:03 AM
I made tests in both Folder LaunchAgents and LaunchDaemons.

I made a chmod 644 on the file.

I don't use developer tool for a such file. I'll try to find it for free.

I'll make the test with your order now.

AFAIK Developer Tools is free, could be wrong though.

danje
Mar 24, 2013, 11:47 AM
I made new test using this .plist generated by plisteditor


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>ServeToMe</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/ServeToMe.app/Contents/MacOS/ServeToMe</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>


I've tried in /Library/LaunchAgents and /Library/LaunchDaemons.

Both try with chmod 644 on the .plist file

Sniffff :'(

danje
Mar 25, 2013, 06:20 AM
Many other try without success :-/

justperry
Mar 25, 2013, 06:26 AM
Many other try without success :-/

What if you put the Application in the startup Folder together with the .plist file?
But, you then need to change the path in the plist file, you also need to set the correct permissions on the Application.

If you do this the path in the plist file should be:

/Library/StartupItems/ServeToMe.app/Contents/MacOS/ServeToMe

Edit: Be careful, it also might be case sensitive.

Example, if I want to kill the finder in Terminal killall finder does not work while killall Finder does!

danje
Mar 25, 2013, 07:35 AM
Oh yes good idea.

I'll try this evening when I'm back from work.

But can I create a SH script called:

Start_ServeToMe.sh
That will point to the application:
/Applications/ServeToMe.app/Contents/MacOS/ServeToMe

Then on the StartupItems, I'll put only the script instead of the executable with the .plist file.

It's just to keep the .app on the /Applications folders.


Thanks for your help and suggestion!

justperry
Mar 25, 2013, 07:52 AM
Oh yes good idea.

I'll try this evening when I'm back from work.

But can I create a SH script called:

Start_ServeToMe.sh
That will point to the application:
/Applications/ServeToMe.app/Contents/MacOS/ServeToMe

Then on the StartupItems, I'll put only the script instead of the executable with the .plist file.

It's just to keep the .app on the /Applications folders.


Thanks for your help and suggestion!

That's another option.

danje
Mar 25, 2013, 03:29 PM
So... I'll cancelled this Idea... it's not working, I've headaches.

I don't understand :-/

danje
Mar 26, 2013, 01:39 AM
I received answer from the ceator of the soft:

Hi Frank,

With the current version of ServeToMe, starting on log in is the only way to start the server automatically. The ServeToMe application requires an active user log in to operate so it will fail if run from launchd.

We are a week or two away from releasing a beta of ServeToMe 4. This version will be a launchd "PrivilegedHelperTools" daemon and will run without an active user log in by default.

Keep an eye on the ServeToMe page here:

http://projectswithlove.com/streamtome/servetome.html

Regards,
Matt Gallagher.

justperry
Mar 26, 2013, 01:44 AM
I received answer from the ceator of the soft:

Hi Frank,

With the current version of ServeToMe, starting on log in is the only way to start the server automatically. The ServeToMe application requires an active user log in to operate so it will fail if run from launchd.

We are a week or two away from releasing a beta of ServeToMe 4. This version will be a launchd "PrivilegedHelperTools" daemon and will run without an active user log in by default.

Keep an eye on the ServeToMe page here:

http://projectswithlove.com/streamtome/servetome.html

Regards,
Matt Gallagher.

No poop.

So, now you know.

Just have to wait 2 more weeks, at least it is solved.