Startup script not working

Status
Not open for further replies.
Hello! I am trying to write a startup script that starts
a webserver (written in python).

The script starts the server if I run it manually after
boot, using: /etc/rc.d/twistd. It does not start automatically
when I boot the server! I have added it in /etc/rc.conf,
and "/etc/rc.d/twistd rcvar" returns "YES".

However, when I start it manually, it says: /etc/rc.d/twistd: DEBUG: pid file (/var/run/twistd.pid): not readable.

Here's the script:

Code:
#!/bin/sh
#
# PROVIDE: twistd
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown

. /etc/rc.subr

name="twistd"
rcvar=`set_rcvar`
command="/usr/local/bin/${name}"

load_rc_config $name

ccg_enable=${ccg_enable-"NO"}

pidfile="/var/run/${name}.pid"

command_args="-y /usr/local/www/ccg.tac"

run_rc_command "$1"
 
twistd should start this way. I don't see anything wrong with this.
Is there no log message explaining what happened during startup?

What happens when you remove the pidfile line? I see /etc/rc.d/devd doesn't have it either, but its running and /var/run/devd.pid exists too.
 
I added --pidfile=/var/run/twistd.pid to the command, and
takes care of the PID error message. When I do
"/etc/rc.d/twistd start" and "/etc/rc.d/twistd status", it says
that the script isn't running. /var/run/twistd.pid exists, and
has the right process number.

It still doesn't start automatically when I reboot.
 
Emm.. so why you put it in /etc/rc.d/ instead of /usr/local/etc/rc.d/ ? =)
Maybe permissions problem?
 
Don't put your own startup scripts in /etc/rc.d/. Use /usr/local/etc/rc.d/.
 
Maybe you can change /usr/local/bin/{$name} temporarily into /usr/local/bin/sh and turn off the command_args.
You get a shell at the point where twistd should start and try it manually.
 
SirDice said:
/etc/rc.d is for the base OS only. Everything else should be put in /etc/local/etc/rc.d.

How it "should be" is no explanation.
Technically it doesn't matter. All rc.d services should be started anyway.

For those who are interested: the end of /etc/rc
Code:
# Do a first pass to get everything up to $early_late_divider so that
# we can do a second pass that includes $local_startup directories
#
files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null`

for _rc_elem in ${files}; do
        run_rc_script ${_rc_elem} ${_boot}

        case "$_rc_elem" in
        */${early_late_divider})        break ;;
        esac
done
 
unset files local_rc

# Now that disks are mounted, for each dir in $local_startup
# search for init scripts that use the new rc.d semantics.
#
case ${local_startup} in
[Nn][Oo] | '') ;;
*)      find_local_scripts_new ;;
esac

files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null`
_skip_early=1
for _rc_elem in ${files}; do
        case "$_skip_early" in
        1)      case "$_rc_elem" in
                */${early_late_divider})        _skip_early=0 ;;
                esac
                continue
                ;;
        esac

        run_rc_script ${_rc_elem} ${_boot}
done
 
MG said:
How it "should be" is no explanation.
Ok. Anything that isn't part of the base OS must use /usr/local/ as a prefix. Is that better?

Technically it doesn't matter. All rc.d services should be started anyway.
Technically you are correct. But keeping the base clutter free is what makes FreeBSD such a nice OS.
 
MG said:
They have no "local" for what I remember.
Which is the reason why I never liked Linux. They install stuff everywhere. There's absolutely no order whatsoever. Just chaos x(
 
I tried following MG's advice, and started up a /bin/sh.

Apparently that python-script can't find some modules...
Is there a way to update the PATH in an rc-script? Setting it
in my .cshrc atleast, doesn't work (probably since the rc-scripts
use /bin/sh).
 
SirDice said:
Ok. Anything that isn't part of the base OS must use /usr/local/ as a prefix. Is that better?

Technically you are correct. But keeping the base clutter free is what makes FreeBSD such a nice OS.


SirDice said:
Which is the reason why I never liked Linux. They install stuff everywhere. There's absolutely no order whatsoever. Just chaos x(

Ports use to install in /usr/local. Nothing else.
Nothing in the Handbook refers to any rule about that.
Considering those facts it probably has nothing to do with this problem and mentioning it can cause chaos instead.
 
MG said:
Ports use to install in /usr/local. Nothing else.
Nothing in the Handbook refers to any rule about that.
Considering those facts it probably has nothing to do with this problem and mentioning it can cause chaos instead.

hier(7)

Code:
         (/usr/)local/    [I]local[/I] executables, libraries, etc.  [I]Also[/I] used as the
                          default destination for the FreeBSD ports framework.
                          Within local/, the general layout sketched out by
                          hier for /usr should be used.  Exceptions are the
                          man directory (directly under local/ rather than
                          under local/share/), ports documentation (in
                          share/doc/<port>/), and /usr/local/etc (mimics
                          /etc).

To me, that reads as 'anything not installed by the base OS, including ports'. Also note that /etc/ is handled by e.g. mergemaster and associated utilities. You don't want your user scripts in there when upgrading.
 
You read it wrong. It's just the description of the directory.
Your whole disk contains local libraries and executables.
The port system's default configuration uses this tree.
You'll have to make the rules -only- for yourself. Don't bother anyone else with them unless there are known system vulnerabilities when doing it different.
 
MG said:
The port system's default configuration uses this tree. You'll have to make the rules -only- for yourself.
Not really. All ports have /usr/local for a prefix. All ports install configs (including startup scripts) in /usr/local/etc/.

Don't bother anyone else with them unless there are known system vulnerabilities when doing it different.
It has nothing to do with system vulnerabilities. It has to do with keeping things organized.

Just see what happens when you submit a new port that doesn't adhere to it.
 
SirDice said:
Not really. All ports have /usr/local for a prefix. All ports install configs (including startup scripts) in /usr/local/etc/.


It has nothing to do with system vulnerabilities. It has to do with keeping things organized.

Just see what happens when you submit a new port that doesn't adhere to it.

Ports install in /usr/local. That's what I said.
Make your own rules about where to keep your own files
And this topic was not about keeping things organized.
Probably there's no need for it, I don't see any related topic. Yahoo forums maybe?
Talin just wants to know why that script does'nt start.
 
I don't read it wrong, you read it too literally. 'Local' means something like 'not belonging to the world', i.e. the base OS. That's the way FreeBSD is organised and how its file hierarchy is laid out. Under your definition of 'local', anything on your system is 'local'.

Oh, and you don't get to decide who 'bothers' whom with what, ok?

Talin, place your start script in /usr/local/etc/rc.d, where the base OS upgrade/install can't clobber it.

P.S.: http://en.wikipedia.org/wiki/Bikeshed#Argument
 
DutchDaemon said:
I don't read it wrong, you read it too literally. 'Local' means something like 'not belonging to the world', i.e. the base OS. That's the way FreeBSD is organised and how its file hierarchy is laid out. Under your definition of 'local', anything on your system is 'local'.

Oh, and you don't get to decide who 'bothers' whom with what, ok?

Talin, place your start script in /usr/local/etc/rc.d, where the base OS upgrade/install can't clobber it.

P.S.: http://en.wikipedia.org/wiki/Bikeshed#Argument

Lol. Feel offended by me saying "don't bother"? Come on, you must have anything better than that. :f

What is was trying to say: why not just try solve the problem by finding its roots? Instead, many people start talking about how one should organize his system and al lot of other subjects. I don't know why, but it doesn't help a lot. It only scares people off, thinking FreeBSD is too difficult, which happens to be nonsense.
 
FreeBSD is not difficult and people won't be confufsed if we say that
/usr/local is for everything you will not find on a fresh FreeBSD install.
So ports and user-generated scripts go there.
 
Status
Not open for further replies.
Back
Top