/srv/irclogs.ubuntu.com/2011/05/20/#upstart.txt

=== Md_ is now known as Md
nibbolike this guy http://serverfault.com/questions/267016/how-can-i-use-upstart-with-vendor-supplied-startup-programs I have two commands for starting/stopping my service. Is it possible to use upstart for this? I guess it bypasses alot of the nice things with upstart though11:14
benccI'm using "limit nofile 20000 20000" at the top of my upstart script16:15
bencchow can I test if this is being set?16:15
teolicyHi. I have an Ubuntu server (10.10) which booted without a runlevel, I'm rather baffled as to why. 'who -r' outputs nothing, and /etc/rcX.d scripts didn't run so I'm missing non-upstart services.17:04
teolicyAnyone here knows what could be the cause? Where in upstart / modern Ubuntu (10.10) can I see the default runlevel?17:04
ionnibbo: Replied at serverfault18:53
benccI'm using limit nofile 20000 20000 for an erlang server20:00
benccbut the "beam" process of the erlang server still has 1024 nofile limit20:01
ionTry20:03
ionlimit nofile 20000 2000020:03
iontask20:03
ionscript20:03
ion  ulimit -a >/tmp/ulimit.out 2>&120:03
ionend script20:03
nibboion: thanks for rocking my socks of!20:03
nibbooff*20:03
nibboNow I am just having the problem of wanting to execute the command in a specific directory. Using script blocks, but a simple "cd" before does not seem to work. Any ideas?20:04
benccion: I don't understand the syntax of the task script part20:04
bencclet me dpaste and see if I got it right20:05
ionnibbo: init(5), /chdir20:05
ionbencc: Just paste all of that to ulimit-test.conf and run ‘start ulimit-test’20:05
benccok20:06
nibboion: Please elaborate. I do not quiet get what you mean.20:06
ionLet me try it here…20:07
ionHere it added to /tmp/ulimit.out: nofiles              2000020:08
ionSo it seems to work at least here.20:08
ionCould beam apply its own limit?20:08
benccion: I've increased the limits to all users so I need to remove it first20:09
ion% ulimit -n 2000 20:10
ion% erl20:10
ion1> os:cmd ("ulimit -n").20:10
ion"2000\n"20:10
ionApparently not.20:10
ionDo you get ‘nofiles 20000’ in /tmp/ulimit.out when you start ulimit-test?20:10
benccion: this is what I got: http://dpaste.com/544785/20:10
benccafter 'sudo start ulimit-test'20:11
ionAlright, Upstart seems to work correctly then.20:11
ionAnd beam doesn’t seem to apply its own limit either. I’m out of ideas.20:11
ionExcept for manual investigation.20:12
benccmaybe beam apply its own limits when it is started by the script in a release20:12
benccwhat do you mean by manual investigation?20:12
benccit defines number of ports with -env ERL_MAX_PORTS 4096 but I don't see settings for nofiles20:13
ionThe usual debugging. Running the service from the command line and seeing if it gets a lower limit. Running it with strace -f -o /tmp/service.strace from Upstart and seeing what sets the limit. Adding ulimit -n calls to various places in the code to see at what point the limit gets set.20:13
benccI'll do that20:14
benccthe start script has RUNNER_USER=myapp20:14
benccmaybe that's changes stuff? because upstart run with root, right?20:14
ionI take it the script doesn’t start a new PAM session? Because that would most likely affect ulimit.20:15
benccit has:20:15
bencc# Make sure this script is running as the appropriate user20:15
benccif [ ! -z "$RUNNER_USER" ] && [ `whoami` != "$RUNNER_USER" ]; then20:15
bencc    exec sudo -u $RUNNER_USER -i $0 $@20:15
benccfi20:15
ionsudo indeed starts a new PAM session.20:16
benccgood than that's the problem20:16
bencccan I do it without sudo?20:16
benccbecause upstart run as root20:16
benccI'm also using sudo in my upstart script which might also be unnecessary 20:17
SpamapSupstart scripts run as root20:17
ionYou could try adding a user-specific entry to /etc/security/limits.conf20:17
benccthat works20:18
ionwhich is used by PAM20:18
SpamapSso su should be sufficient20:18
benccdoing this in upstart make it much more portable20:18
benccthat's what make upstart so cool20:18
benccSpamapS: su doesn't start a new PAM?20:18
benccinstead of 'exec sudo -u myapp -i myapp start' I need 'exec su -u myapp -i myapp start' ?20:19
SpamapSit does with -l20:19
benccSpamapS so what is the correct way to run a script in upstart as another user?20:19
SpamapSsu is the recommended way, not sure there is a "correct" way20:20
SpamapSIts been suggested that a 'user' stanza would make sense.20:20
benccdoes 'exec su -u myapp -i myapp start' starts a new PAM?20:20
* SpamapS would prefer it be 'run as [user x] [group y]' to keep the upstart stanzas as imperative as possible20:21
SpamapSbencc: I don't know that it actually runs login.. you should test it20:21
SpamapSbencc: certainly if it doesn't, and thats what you need.. then maybe sudo is more appropriate.20:21
benccnot sure I understand20:22
ionBoth su and sudo start a PAM session.20:22
benccif "limit nofile 20000 20000" works but a command that run a script as another user starts a new PAM than what's the point with the limit nofile setting20:22
iondaemontools seems to come with /usr/bin/setuidgid which might be useful here.20:24
ionThe daemontools package20:24
benccthanks20:26
benccmaybe editing limits.conf is the correct way to do it20:27
benccI just don't know20:27

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!