[17:21] <diverdude> i 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] <diverdude> comm="/sbin/init"). What am I doing wrong?
[17:22] <SpamapS> diverdude: you can't run start/stop on system jobs as non-root
[17:22] <diverdude> ahhh
[17:23] <diverdude> dog
[17:23] <diverdude> doh
[17:23] <diverdude> :D
[17:23] <diverdude> thx
[17:23] <SpamapS> diverdude: sudo is your friend
[17:23] <diverdude> yes
[17:23] <diverdude> that worked
[17:23] <diverdude> bu
[17:23] <diverdude> t
[17:23] <diverdude> when i do sudo stop nodechatserver i get stop: Unknown instance: 
[17:24] <SpamapS> that means it died
[17:25] <SpamapS> diverdude: 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.log
[17:25] <SpamapS> diverdude: that creates a PAM session, which can cause issues if the job isn't stopped
[17:26] <SpamapS> diverdude: which, btw, it won't be, because there is no such event as "shutdown"
[17:26] <diverdude> SpamapS: i see...what is a better way to do it?
[17:26] <SpamapS> diverdude: 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.log
[17:26] <diverdude> ah right
[17:26] <diverdude> im in 12.04
[17:27] <SpamapS> diverdude: http://upstart.ubuntu.com/cookbook/#run-a-job-as-a-different-user
[17:27] <diverdude> but it would be nice to have the log in a special file though
[17:27] <SpamapS> diverdude: also 'startup' is emitted before filesystems are mounted, before the network is up.. WAY too early
[17:27] <SpamapS> diverdude: you want 'start on runlevel [2345]' and 'stop on runlevel [^2345]'
[17:29] <diverdude> SpamapS: mmm i see....is that easy to do?
[17:30] <SpamapS> diverdude: is what easy to do?
[17:30] <diverdude> SpamapS: to 'start on runlevel [2345]' and 'stop on runlevel [^2345]'
[17:31] <SpamapS> diverdude: yes, just change the two start on / stop on lines in your file
[17:32] <diverdude> SpamapS: do you think you could show me an example by modifying http://bin.cakephp.org/view/445950409?
[17:37] <SpamapS> diverdude: http://bin.cakephp.org/view/445950409
[17:41] <diverdude> SpamapS: ahhh nice. thanks
[17:42] <diverdude> SpamapS: mmm should i restart before i can use it?
[17:42] <diverdude> because when i run it i get this: 
[17:42] <diverdude> $ sudo start nodechatserver 
[17:42] <diverdude> nodechatserver stop/waiting
[17:42] <diverdude> and stop it says this
[17:42] <diverdude> $ sudo stop nodechatserver 
[17:42] <diverdude> stop: Unknown instance:
[17:42] <SpamapS> diverdude: your start is very odd. I would check the log for errors
[17:43] <SpamapS> diverdude: 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:49] <diverdude> hmm
[17:50] <diverdude> cat /var/log/nodejs.log is totally empty
[17:50] <diverdude> cat /var/log/upstart/nodechatserver.log 
[17:50] <diverdude> cat: /var/log/upstart/nodechatserver.log: Permission denied
[17:55] <SpamapS> diverdude: sudo again
[17:56] <diverdude> you mean sudo start nodechatserver ?
[17:56] <diverdude> i did that
[17:56] <SpamapS> no
[17:56] <SpamapS> sudo cat /var/log/upstart/nodechatserver.log
[18:03] <diverdude> it says start-stop-daemon: unable to stat /usr/local/bin/node (No such file or directory) in the logfile
[18:03] <diverdude> but this file exists
[18:03] <diverdude> i can run it manually
[18:04] <SpamapS> diverdude: interesting
[18:04] <SpamapS> diverdude: check for sure that there's no type-o
[18:04] <SpamapS> diverdude: 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:11] <diverdude> SpamapS: sorry that was my mistake
[18:11] <diverdude> it can run now
[18:11] <diverdude> nodechatserver start/running, process 14555
[18:11] <diverdude> however still cannot stop it :(
[18:13] <SpamapS> diverdude: how so?
[18:13] <SpamapS> diverdude: is it actually running?
[18:16] <diverdude> hmm no
[18:16] <diverdude> ps aux | grep 14555 shows nothing :(
[18:16] <diverdude> ahh i know why
[18:17] <diverdude> is it possible to run the process from a certain directory?
[18:17] <diverdude> like if i want to cd /somewhere first
[18:18] <diverdude> would 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:25] <diverdude> hmm
[18:25] <diverdude> its not running
[18:26] <SpamapS> diverdude: yes there is a 'chdir' stanza
[18:26] <diverdude> even though the output in cat /var/log/nodejs.log looks correct
[18:26] <SpamapS> diverdude: don't exec cd
[18:26] <SpamapS> diverdude: 'chdir /home/bdi/www/myproj....' at the root of the charm
[18:26] <diverdude> SpamapS: i fixed the CD in another way, so thats not necessary after all
[18:26] <diverdude> SpamapS: but still for some reason its not running
[18:26] <SpamapS> diverdude: actually for your charm, you don't even need start-stop-daemon, you can do 'setuid www-data' and 'setgid www-data'
[18:27] <SpamapS> diverdude: does nodejs daemonize?
[18:27] <SpamapS> diverdude: like, when you run it from the commandline, does it give you back your shell immediately even though it is running?
[18:27] <diverdude> SpamapS: hmm i think so...cant all programs do that?
[18:27] <diverdude> SpamapS: i dont know actually
[18:28] <diverdude> SpamapS: im pretty sure though...these guys: http://kvz.io/blog/2009/12/15/run-nodejs-as-a-service-on-ubuntu-karmic/ demonised it
[18:30] <diverdude> SpamapS: dont you think?
[18:32] <SpamapS> *karmic* ?
[18:33] <SpamapS> diverdude: thats 3 years old now.. ;)
[18:33] <SpamapS> node has come quite a long way since then
[18:33] <diverdude> SpamapS: hehe yes...but i dont suppose it has gotten worse?
[18:33] <SpamapS> diverdude: but if it is dying.. its not upstart killing it.
[18:33] <SpamapS> diverdude: check /var/log/syslog, you should have something like "init: ... exitted with code 1"
[18:35] <diverdude> SpamapS: yeah
[18:35] <diverdude> init: nodechatserver main process (14722) terminated with status 1
[18:36] <diverdude> SpamapS: what does that mean?
[18:37] <SpamapS> diverdude: it means it exitted with an error
[18:37] <SpamapS> diverdude: I'm sure your log will show the error
[18:37] <diverdude> no
[18:37] <diverdude> nothing in the log
[18:39] <diverdude> and this runs just fine if i do it manually
[18:39] <diverdude> sudo -u www-data /usr/bin/nodejs /home/bdi/www/myproj/Console/Command/Nodejs/ChatHandler/ChatServer.js
[18:41] <diverdude> thats very strange 
[18:41] <diverdude> hmm
[18:41] <diverdude> SpamapS: ^
[18:47] <jodh> diverdude: Have you looked at the Upstart Cookbook? Specifically, try: http://upstart.ubuntu.com/cookbook/#checking-how-a-service-might-react-when-run-as-a-job
[19:36] <diverdude> jodh: hmm i tried doing:
[19:36] <diverdude> user=www-data
[19:36] <diverdude> cmd="/usr/bin/node /home/bdi/www/myproject/Console/Command/Nodejs/ChatHandler/ChatServer.js"
[19:36] <diverdude> su -c 'nohup env -i $cmd </dev/null >/dev/null 2>&1 &' $user
[19:36] <diverdude> and i get: 
[19:37] <diverdude> su: Authentication failure
[19:37] <diverdude> is that the reason for it not running?
[19:37] <diverdude> and is my cmd set up correctly?
[19:42] <jodh> diverdude: I think you just got that password wrong.
[19:43] <diverdude> jodh: no
[19:43] <diverdude> i tried 4 times
[21:11] <diverdude> SpamapS: are you still there?
[22:51] <SpamapS> diverdude: I stepped out for a bit, back now
[23:30] <diverdude> SpamapS: start on runlevel [2345] ensures that service is started after network interface cards are up right?