View Full Version : [Solved] Startup script not working
talin
August 12th, 2009, 08:50
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:
#!/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"
MG
August 12th, 2009, 09:11
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.
talin
August 12th, 2009, 09:15
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.
Alt
August 12th, 2009, 09:57
Emm.. so why you put it in /etc/rc.d/ instead of /usr/local/etc/rc.d/ ? =)
Maybe permissions problem?
SirDice
August 12th, 2009, 10:04
Don't put your own startup scripts in /etc/rc.d/. Use /usr/local/etc/rc.d/.
MG
August 12th, 2009, 10:05
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.
MG
August 12th, 2009, 10:08
Don't put your own startup scripts in /etc/rc.d/. Use /usr/local/etc/rc.d/.
Explanation?
SirDice
August 12th, 2009, 10:11
Explanation?
/etc/rc.d is for the base OS only. Everything else should be put in /etc/local/etc/rc.d.
MG
August 12th, 2009, 10:24
/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
# 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
Alt
August 12th, 2009, 10:26
Have you used linux before? :D
MG
August 12th, 2009, 10:37
Have you used linux before? :D
I did, Slackware, slaptgetted my desktop together. :beergrin
They have no "local" for what I remember.
SirDice
August 12th, 2009, 10:40
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.
SirDice
August 12th, 2009, 10:42
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(
talin
August 12th, 2009, 11:26
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).
MG
August 12th, 2009, 11:45
export PATH=$PATH:/dir1:/dir2
MG
August 12th, 2009, 11:52
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.
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.
talin
August 12th, 2009, 11:56
Perfect, that works. Thank you!
DutchDaemon
August 12th, 2009, 12:05
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
(/usr/)local/ local executables, libraries, etc. Also 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.
MG
August 12th, 2009, 13:36
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.
SirDice
August 12th, 2009, 13:45
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.
MG
August 12th, 2009, 14:02
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.
DutchDaemon
August 12th, 2009, 14:10
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
MG
August 13th, 2009, 07:48
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.
lme@
August 13th, 2009, 09:10
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.
DutchDaemon
August 13th, 2009, 11:04
Right. And that's enough ;)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.
0