Forum

Full Version: Screen and dtach sessions show as main in process manager
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
Every time when I try to start my daemon
start-stop-daemon --chuid $USER --start --name $NAME --nicelevel $NICE --background --pidfile $PID_FILE --make-pidfile --exec /usr/bin/dtach -- -n $TMP /usr/local/bin/rtorrent -n -o import=$CONFIG_FILE

My pid file is showing process that don't exist and this process is showed in top as main. What can be a cause of this? I'm trying to make package for xbian but can't make proper stop script for thisBig Grin, and can't kill the process

Here's my current init.d file:
https://github.com/koper89/xbian-rtorrent/blob/master/content/etc/init.d/rtorrent

if you want to test my rtorrent package:
https://github.com/koper89/xbian-rtorrent
Don't create init.d scripts but rather use upstart ones. Check the /etc/init/ folder for examples.
Ok, I'll check those, and maybe you have any suggestions about using screen dtach t-mux? I wanted to make it as lightweight as I could that's why I choose dtach but maybe you'll have some suggestions and prefer screen t-mux?

But i suppouse upstart will not solve "main" problem
Sorry to double post but I suppouse I need more explanation here:
1. I tried on upstart and init.d script
2. Every time I start my dtach or screen session it start as f.e. rtorrent and PID 12100 and after few seconds it changes to main and PID 12101 and I can't stop my process because it's no longer recognized by my script
3. I tried on screen and dtach

What can be a cause of this
it's just a idea,
as i don't know so much about upstart,
but look at this
http://upstart.ubuntu.com/cookbook/#expect
But it's not a problem in upstart, it's general problem in using screen or dtach in xbian since RC2 i suppouse, I have always change PID and name of the process to main..
Why are you using both programs in the first place? Just start rtorrent directly in your upstart script.

Simple example from pilight:
Code:
#!upstart

description "start rtorrent"

start on started mountall and net-device-up
stop on runlevel [016]

exec /usr/local/bin/rtorrent -n -o import=$CONFIG_FILE
Try this one (i adapted from my pilight init).
I said I checked it on both of them not using both at a time.
Rtorrent doesn't have a daemon so i suppouse screen or dtach is a must, but maybe I don't understand how upstart works....
And I found what was the cause of my problem it was not screen/upstart/init.d it's propably a bug in rtorrent 0.9.4 when i downgraded to 0.9.3 it's solved and it shows properly rtorrent not mainSmile I'll make 3 packages for xbian with
rtorrent 0.9.2 (because some trackers don't allow 0.9.3)
rtorrent 0.9.3
and dev with 0.9.4 (it's marked as stable but I found that it have a lot of memory leaks which is really visible on raspberry Pi)

And should I compile nginx and other dependancies and include them in package, or marking them as dependancies will do the work, as I currently do?

Btw. I have also a question about sickbeard-tpb package, (maybe i shouldn't post it hereTongue) But why should I add current files of f.e. sickbeard in xbian package, and not use git clone in post install to always get newest version ?

Best wishes
If you'd actually tried my suggestion, you would have noticed that it was the right way to go Confused It doesn't matter to upstart if something daemonizes or not, as long as you configure your upstart script correctly.

Proof of concept
Code:
cat <<\EOF > /root/test.sh
#!/bin/bash

while [ 1 ]; do
        sleep 1;
done;
EOF
chmod +x test.sh
cat <<\EOF > /etc/init/test.conf
#!upstart

description "start test"

start on started mountall and net-device-up
stop on runlevel [016]

exec /root/test.sh
EOF
initctl reload-configuration

Just copy and paste everything between the code tags at once in your terminal. Then try:
Code:
service test start
service test stop

However, if you do this in your upstart script
Code:
exec /root/test.sh &
You also need to add:
Code:
expect fork
I think you're not right, I tested your script (and without dtach or screen it's not working). Don't know why exactly but never find rtorrent running without screen/dtach/tmux.
Reference URL's