Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

node.js app auto started by upstart

  • Loading branch information...
commit 801c7dfe0677ebcb0b6bc17766d47624b2a1c78a 1 parent d415adc
@truepattern authored
View
1  Vagrantfile
@@ -41,6 +41,7 @@ Vagrant::Config.run do |config|
# add mysite to webserver
chef.add_recipe("mysite")
+ chef.add_recipe("mysite::node")
# add node.js
chef.add_recipe "nodejs"
View
6 readme.md
@@ -26,10 +26,10 @@ Following softwares are installed to the vbox
### Node.js App
* The sample app is in 'app' directory
* ssh to virtualbox
-
+
```bash
-cd app
-node server.js
+# node is automatically started by upstart and should be running already
+ps -aef | grep node
```
* go to your host box, browser and try http://localhost:8080
View
17 site-cookbooks/mysite/files/default/nodejs.conf
@@ -0,0 +1,17 @@
+#!upstart
+description "node.js application"
+
+start on startup
+stop on shutdown
+
+#Send KILL after 5 seconds
+kill timeout 5
+respawn
+
+#script details
+script
+ export HOME="/home/vagrant"
+ NODE_ENV=production
+ exec sudo -u vagrant NODE_ENV=production node $HOME/app/server.js 2>&1 >> /var/log/node.log
+end script
+
View
12 site-cookbooks/mysite/recipes/default.rb
@@ -11,15 +11,3 @@
nginx_site "mysite"
-#nginx_site "mysite" do
- #template "nginx/mysite.conf.erb"
- #action :enable
-#end
-
-#
-#directory "/var/www/construction" do
- #owner "www-data"
- #group "sdmin"
- #mode "0755"
-#end
-
View
15 site-cookbooks/mysite/recipes/node.rb
@@ -0,0 +1,15 @@
+cookbook_file "/etc/init/mysite-nodejs.conf" do
+ source "nodejs.conf"
+ owner "root"
+ group "root"
+ mode 0644
+end
+
+service "mysite-nodejs" do
+ provider Chef::Provider::Service::Upstart
+ enabled true
+ running true
+ supports :restart => true, :reload => true, :status => true
+ action [:enable, :start]
+end
+

0 comments on commit 801c7df

Please sign in to comment.
Something went wrong with that request. Please try again.