Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to start aria2 as a daemon on startup on Raspberry Pi headless server (no GUI, just SSH access)

I created a service aria2cRPC that starts the application (got help from: http://www.megaleecher.net/Raspberry_Pi_Autostart) It starts the app like this:

sudo aria2c --daemon --enable-rpc --rpc-listen-all

When I start the service from SSH console

sudo service aria2cRPC start

Everythink works as expected.

But when I add the service to autostart on boot, it won't start.

sudo update-rc.d aria2cRPC defaults

Should I change the runlevel? Which level should I use? How can I test that the service is at least trying to start on boot?

EDIT: When I look into /etc/rcX.d I can see my service at:

/etc/rc0.d K01aria2cRPC
/etc/rc1.d K01aria2cRPC
/etc/rc2.d S01aria2cRPC
/etc/rc3.d S01aria2cRPC
/etc/rc4.d S01aria2cRPC
/etc/rc5.d S01aria2cRPC
/etc/rc6.d K01aria2cRPC

Does it mean that the service should be running when booted without X (run level 2,3,4)?

share|improve this question

2 Answers 2

I believe that the default run level for the Raspberry Pi is 2, so the default settings should be OK. You can check if that's indeed the case by invoking who -r.

The sequence number that you used (01) is quite low. This could be reason enough for the service not to start, if it depends on other services that have higher sequence numbers. I suggest that you try again with a higher one, e.g.

sudo update-rc.d aria2cRPC defaults 99

after removing the links.

Should I change the runlevel? Which level should I use?

You don't have to change your run level, unless you have other reasons for doing so.

How can I test that the service is at least trying to start on boot?

You can add a line like the following to your /etc/init.d/aria2cRPC script:

echo "`/bin/date` $1" >> /var/tmp/aria-rc.log

which will log all of your script invocations. ($1 will be the script's first parameter, start or stop).

share|improve this answer
    
Ok, so I've checked with runlevel and it is level 2. I renamed the file to /etc/rc2.d S90aria2cRPC (using mv). I was thinking maybe there is a problem with running sudo in the shell script, so I added a line at the very end of sudo visudo: pi ALL=(ALL) NOPASSWD: /usr/bin/aria2c But it won't help.. any other ideas? –  Joudicek Jouda Oct 8 '13 at 22:29
    
Of course you have checked that the target of your links (your /etc/init.d/aria2cRPC script) is owned by root:root and has permissions 755. –  nickie Oct 8 '13 at 22:35
    
I added the echo line just next to the aria2c line and the script is starting on boot. So the problem must be with calling the application. The script is owned by root and has permission 777. Is it ok? What about the application (also root and 755) - should I modify the ownership or permissions? –  Joudicek Jouda Oct 8 '13 at 23:42
    
It may not be the cause of the problem but you should fix the permissions. You'll need to debug your script and I don't think I can help much without being able to put my hands on it. –  nickie Oct 9 '13 at 0:06
    
OK, how should I fix those? I mean I have no problem Googling commands, but I don't know to what should I set those? Like 755 on every file/script? Should all of them be owned by user pi? The script is the same as the script it step 3 here: megaleecher.net/Raspberry_Pi_Autostart But the line starting the application (nohup ... ) is like the one in my question - I changed it because the line didn't start aria2c daemon even from SSH.. –  Joudicek Jouda Oct 9 '13 at 0:30
up vote 1 down vote accepted

The solution is to create a blank txt file which path is specified in aria2 config: input-file.

Aria2 is not able to handle the situation when there is some file path specified, but it doesn't exist. So it won't start. But also doesn't display any error which is quite tricky.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.