Daemon basics - How To?

Ask for help and report issues not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
Pierobon
Posts: 16
Joined: Fri Oct 19, 2012 8:17 pm

Daemon basics - How To?

Post by Pierobon »

Ok guys, Im very tired to roam around the wiki reading scripts and trying all possible and imaginable setups ever.
I promise that after i'm successful trying to run my transmission daemon, I WILL write down some as-detailed-as-i-can-possibly-do documentation for running transmission daemon on a macintosh.

But right now, i'm already trying to do it for a little more than 6 months, and still have not even succeeded to make the daemon start correctly.
Whatever I try, it will never read the config files, and if I run it in a brand new virgin state, it always have permission problems to write down the downloads to disk.
Also, I will give an example this time: I open a new terminal window, cd to daemon folder and do start command. until here, all good, activity monitor shows process named transmission-daemon. Then I type something like "./transmission-daemon -et" and instead of configuring the daemon, it just opens a new daemon instance, and now activity monitor shows 2 processes named transmission-daemon.and if I keep trying to config the daemon from the terminal, instead it will just keep opening additional instances of transmissions for every single line I type in terminal - even if I try "./transmission-daemon stop", it just opens a new transmission instance.

Just to keep it simple for you guys, I am trying to simply open a terminal window and run the daemon, without scripts, without nothing else. I just want to first learn how to do everything manually on the daemon.

So please, I need your help guys!
Can you help me with this?
Thank you very much!

First question:
How do I start and stop transmission-daemon from terminal?
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: Daemon basics - How To?

Post by blacke4dawn »

Any configuration you want to do on an already running instance needs to be done via transmission-remote, not by starting another daemon instance. There is no built in stop command in the daemon itself, you have to use "transmission-remote --exit".

The two option you could start with to see if the daemon really has permission problems would be -g (directory that will contain config files, resume files, loaded torrents and such) and -w (default download location).
Pierobon
Posts: 16
Joined: Fri Oct 19, 2012 8:17 pm

Re: Daemon basics - How To?

Post by Pierobon »

OMG, I could finally put it to work, i didn't change any permissions. Just configured it from remote and it's already downloading, auto-ading, and everything. (Just did 500MB, so it's way beyond cache limits.)
:arrow: Thumbs up to blacke4dawn :mrgreen:

Now, next question is about Mac OSX launchd capabilities.
Official launchd manual here.
I made it work.
The only issue is that I can't use the KeepAlive key, otherwise OSX itself will launch one instance of transmission-daemon every 10 or 15 seconds.
I would like very much to implement the keep alive option, in some way that is compatible with the transmission-daemon executable. Help!

Here is my plist file (you may call daemon start-up script), as it is working now:

Code: Select all

<?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>Label</key>
		<string>local.transmission-daemon</string>
	<key>UserName</key>
		<string>server</string>
	<key>Program</key>
		<string>/Users/server/Applications/Transmission/transmission-daemon</string>
	<key>KeepAlive</key>
		<false/>
	<key>RunAtLoad</key>
		<true/>
	<key>EnvironmentVariables</key>
		<dict>
			<key>TRANSMISSION_WEB_HOME</key>
			<string>/Users/server/Applications/Transmission/web/</string>
		</dict>
</dict>
</plist>
If you want to test this, but never heard about launchd and it's plist files:
copy this file into a new text edit file, make sure it is plain text and save as *.plist
move to folder /Library/LaunchDaemons/
change ownership of this *.plist file to root (just plist file, no need to change any other files).
reboot machine (or do terminal launchctl load /Library/LaunchDaemons/*.plist)

and to disable the script just move the *.plist file to any other folder that suits you best.
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: Daemon basics - How To?

Post by blacke4dawn »

I don't use (nor have) OSX so can't help you with that part.
Pierobon
Posts: 16
Joined: Fri Oct 19, 2012 8:17 pm

Re: Daemon basics - How To?

Post by Pierobon »

blacke4dawn wrote:I don't use (nor have) OSX so can't help you with that part.
Haha, it's ok, i'm happy already! =D

Someone else might now it.
Pierobon
Posts: 16
Joined: Fri Oct 19, 2012 8:17 pm

Re: Daemon basics - How To?

Post by Pierobon »

Bump!!! First and last time.

I am now starting to look for this answer in stack-exchange and other websites too, so if someone want's to help me put this to work, please be welcome!
Pierobon
Posts: 16
Joined: Fri Oct 19, 2012 8:17 pm

Re: Daemon basics - How To?

Post by Pierobon »

Brucewave wrote:Well,that's very interesting.
I'm sorry for what I missed, but what exactly is very interesting?

Updating the issue, I managed to launch transmission-daemon on system startup using OSX launchd.
The problem is that I can NOT use the launchd keep alive option, because it simply starts a new instance of transmission-daemon every 10 seconds or so, and it never stops opening new instances.
The way it is working now, launchd opens transmission-daemon one single time, and if for any reason it crashes, system needs to be rebooted for it to launch again. I don't understand why. Can someone please take a look at this? Thanks.
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: Daemon basics - How To?

Post by blacke4dawn »

Pierobon wrote:
Brucewave wrote:Well,that's very interesting.
I'm sorry for what I missed, but what exactly is very interesting?
It's a disguised advert post, look at the bottom of it.
Updating the issue, I managed to launch transmission-daemon on system startup using OSX launchd.
The problem is that I can NOT use the launchd keep alive option, because it simply starts a new instance of transmission-daemon every 10 seconds or so, and it never stops opening new instances.
The way it is working now, launchd opens transmission-daemon one single time, and if for any reason it crashes, system needs to be rebooted for it to launch again. I don't understand why. Can someone please take a look at this? Thanks.
Not sure how it handles that but I would look into if it tracks the PID somewhere, and thus make sure it knows which is the correct one.
phyllisstein
Posts: 1
Joined: Tue Jul 09, 2013 3:33 pm

Re: Daemon basics - How To?

Post by phyllisstein »

A Twitter friend of mine just figured out the answer to this one, which had been bugging me for some time as well. You should try adding the --foreground argument to your transmission-daemon command. Apparently launchd can only determine whether and how a process has terminated if it stays in the foreground, so it detects the switch into daemon mode as a bad exit and launches a new copy. With --foreground added, this has been working fine for me:

Code: Select all

<?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>
	<dict>
		<key>NetworkState</key>
		<true/>
		<key>SuccessfulExit</key>
		<false/>
	</dict>
	<key>Label</key>
	<string>com.danielsh.transmission-daemon</string>
	<key>ProgramArguments</key>
	<array>
		<string>/bin/transmission-daemon</string>
		<string>--foreground</string>
		<string>--log-error</string>
		<string>--log-info</string>
		<string>--logfile=/Users/danielsh/Library/Logs/transmission-daemon.log</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>
Post Reply