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