/srv/irclogs.ubuntu.com/2012/10/12/#upstart.txt

diverdudei made this configscript: http://bin.cakephp.org/view/445950409 and saved it in: /etc/init/nodechatserver.conf. when i run start nodechatserver i get this error messae: start: Rejected send message, 1 matched rules; type="method_call", sender=":1.11" (uid=1000 pid=14091 comm="start nodechatserver ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 17:21
diverdudecomm="/sbin/init"). What am I doing wrong?17:21
SpamapSdiverdude: you can't run start/stop on system jobs as non-root17:22
diverdudeahhh17:22
diverdudedog17:23
diverdudedoh17:23
diverdude:D17:23
diverdudethx17:23
SpamapSdiverdude: sudo is your friend17:23
diverdudeyes17:23
diverdudethat worked17:23
diverdudebu17:23
diverdudet17:23
diverdudewhen i do sudo stop nodechatserver i get stop: Unknown instance: 17:23
SpamapSthat means it died17:24
SpamapSdiverdude: you should note that this is not the best way to switch users...17:25
SpamapS    exec sudo -u www-data /usr/local/bin/node /home/bdi/www/myproj/Console/Command/Nodejs/ChatHandler/ChatServer.js 2>&1 >> /var/log/nodejs.log17:25
SpamapSdiverdude: that creates a PAM session, which can cause issues if the job isn't stopped17:25
SpamapSdiverdude: which, btw, it won't be, because there is no such event as "shutdown"17:26
diverdudeSpamapS: i see...what is a better way to do it?17:26
SpamapSdiverdude: also if you are on Ubuntu 11.10 or later, the job output will be logged, so no need to 2>&1 to a special log.. it will automatically be in /var/log/upstart/name_of_job.log17:26
diverdudeah right17:26
diverdudeim in 12.0417:26
SpamapSdiverdude: http://upstart.ubuntu.com/cookbook/#run-a-job-as-a-different-user17:27
diverdudebut it would be nice to have the log in a special file though17:27
SpamapSdiverdude: also 'startup' is emitted before filesystems are mounted, before the network is up.. WAY too early17:27
SpamapSdiverdude: you want 'start on runlevel [2345]' and 'stop on runlevel [^2345]'17:27
diverdudeSpamapS: mmm i see....is that easy to do?17:29
SpamapSdiverdude: is what easy to do?17:30
diverdudeSpamapS: to 'start on runlevel [2345]' and 'stop on runlevel [^2345]'17:30
SpamapSdiverdude: yes, just change the two start on / stop on lines in your file17:31
diverdudeSpamapS: do you think you could show me an example by modifying http://bin.cakephp.org/view/445950409?17:32
SpamapSdiverdude: http://bin.cakephp.org/view/44595040917:37
diverdudeSpamapS: ahhh nice. thanks17:41
diverdudeSpamapS: mmm should i restart before i can use it?17:42
diverdudebecause when i run it i get this: 17:42
diverdude$ sudo start nodechatserver 17:42
diverdudenodechatserver stop/waiting17:42
diverdudeand stop it says this17:42
diverdude$ sudo stop nodechatserver 17:42
diverdudestop: Unknown instance:17:42
SpamapSdiverdude: your start is very odd. I would check the log for errors17:42
SpamapSdiverdude: note that having it in /var/log/upstart/jobname.log will really be easier.. /var/log/nodejs.log is pretty generic, don't you think?17:43
diverdudehmm17:49
diverdudecat /var/log/nodejs.log is totally empty17:50
diverdudecat /var/log/upstart/nodechatserver.log 17:50
diverdudecat: /var/log/upstart/nodechatserver.log: Permission denied17:50
SpamapSdiverdude: sudo again17:55
diverdudeyou mean sudo start nodechatserver ?17:56
diverdudei did that17:56
SpamapSno17:56
SpamapSsudo cat /var/log/upstart/nodechatserver.log17:56
diverdudeit says start-stop-daemon: unable to stat /usr/local/bin/node (No such file or directory) in the logfile18:03
diverdudebut this file exists18:03
diverdudei can run it manually18:03
SpamapSdiverdude: interesting18:04
SpamapSdiverdude: check for sure that there's no type-o18:04
SpamapSdiverdude: and when you say you can run it manually, are you running just /usr/local/bin/node, or the full start-stop-daemon command?18:04
diverdudeSpamapS: sorry that was my mistake18:11
diverdudeit can run now18:11
diverdudenodechatserver start/running, process 1455518:11
diverdudehowever still cannot stop it :(18:11
SpamapSdiverdude: how so?18:13
SpamapSdiverdude: is it actually running?18:13
diverdudehmm no18:16
diverdudeps aux | grep 14555 shows nothing :(18:16
diverdudeahh i know why18:16
diverdudeis it possible to run the process from a certain directory?18:17
diverdudelike if i want to cd /somewhere first18:17
diverdudewould that by exec start-stop-daemon --start -c www-data --exec cd /home/bdi/www/myproj/Console/Command/Nodejs/ChatHandler/ ; /usr/bin/nodejs -- /home/bdi/www/myproj/Console/Command/Nodejs/ChatHandler/ChatServer.js 2>&1 >> /var/log/nodejs.log    ?18:18
diverdudehmm18:25
diverdudeits not running18:25
SpamapSdiverdude: yes there is a 'chdir' stanza18:26
diverdudeeven though the output in cat /var/log/nodejs.log looks correct18:26
SpamapSdiverdude: don't exec cd18:26
SpamapSdiverdude: 'chdir /home/bdi/www/myproj....' at the root of the charm18:26
diverdudeSpamapS: i fixed the CD in another way, so thats not necessary after all18:26
diverdudeSpamapS: but still for some reason its not running18:26
SpamapSdiverdude: actually for your charm, you don't even need start-stop-daemon, you can do 'setuid www-data' and 'setgid www-data'18:26
SpamapSdiverdude: does nodejs daemonize?18:27
SpamapSdiverdude: like, when you run it from the commandline, does it give you back your shell immediately even though it is running?18:27
diverdudeSpamapS: hmm i think so...cant all programs do that?18:27
diverdudeSpamapS: i dont know actually18:27
diverdudeSpamapS: im pretty sure though...these guys: http://kvz.io/blog/2009/12/15/run-nodejs-as-a-service-on-ubuntu-karmic/ demonised it18:28
diverdudeSpamapS: dont you think?18:30
SpamapS*karmic* ?18:32
SpamapSdiverdude: thats 3 years old now.. ;)18:33
SpamapSnode has come quite a long way since then18:33
diverdudeSpamapS: hehe yes...but i dont suppose it has gotten worse?18:33
SpamapSdiverdude: but if it is dying.. its not upstart killing it.18:33
SpamapSdiverdude: check /var/log/syslog, you should have something like "init: ... exitted with code 1"18:33
diverdudeSpamapS: yeah18:35
diverdudeinit: nodechatserver main process (14722) terminated with status 118:35
diverdudeSpamapS: what does that mean?18:36
SpamapSdiverdude: it means it exitted with an error18:37
SpamapSdiverdude: I'm sure your log will show the error18:37
diverdudeno18:37
diverdudenothing in the log18:37
diverdudeand this runs just fine if i do it manually18:39
diverdudesudo -u www-data /usr/bin/nodejs /home/bdi/www/myproj/Console/Command/Nodejs/ChatHandler/ChatServer.js18:39
diverdudethats very strange 18:41
diverdudehmm18:41
diverdudeSpamapS: ^18:41
jodhdiverdude: Have you looked at the Upstart Cookbook? Specifically, try: http://upstart.ubuntu.com/cookbook/#checking-how-a-service-might-react-when-run-as-a-job18:47
diverdudejodh: hmm i tried doing:19:36
diverdudeuser=www-data19:36
diverdudecmd="/usr/bin/node /home/bdi/www/myproject/Console/Command/Nodejs/ChatHandler/ChatServer.js"19:36
diverdudesu -c 'nohup env -i $cmd </dev/null >/dev/null 2>&1 &' $user19:36
diverdudeand i get: 19:36
diverdudesu: Authentication failure19:37
diverdudeis that the reason for it not running?19:37
diverdudeand is my cmd set up correctly?19:37
jodhdiverdude: I think you just got that password wrong.19:42
diverdudejodh: no19:43
diverdudei tried 4 times19:43
diverdudeSpamapS: are you still there?21:11
SpamapSdiverdude: I stepped out for a bit, back now22:51
diverdudeSpamapS: start on runlevel [2345] ensures that service is started after network interface cards are up right?23:30

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