Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use upstart on Ubuntu to launch razor #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@ def default_postrgres_port
default['razor']['rubygems_source']['version'] = src_version = "1.8.24"
default['razor']['rubygems_source']['url'] =
"http://files.rubyforge.vm.bytemark.co.uk/rubygems/rubygems-#{src_version}.tgz"

case node['platform']
when "ubuntu"
default['razor']['service_type'] = "upstart"
else
default['razor']['service_type'] = "sysvinit"
end
15 changes: 0 additions & 15 deletions recipes/_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,3 @@

notifies :restart, "service[razor]"
end

template "/etc/init.d/razor" do
source "razor.erb"
mode "0755"
variables({
:directory => install_path
})

notifies :restart, "service[razor]"
end

service "razor" do
supports :status => true, :restart => true, :reload => false
action [ :enable, :start ]
end
54 changes: 54 additions & 0 deletions recipes/_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Cookbook Name:: razor
# Recipe:: _service
#
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
#
# Copyright 2012, Blue Box Group, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

case node['razor']['service_type']
when "sysvinit"
template "/etc/init.d/razor" do
source "razor.erb"
mode "0755"
variables({
:directory => node['razor']['install_path']
})

notifies :restart, "service[razor]"
end

service "razor" do
supports :status => true, :restart => true, :reload => false
action [ :enable, :start ]
end
when "upstart"
template "/etc/init/razor.conf" do
source "razor.upstart.erb"
mode "0644"
variables(
:install_path => node['razor']['install_path']
)
notifies :stop, "service[razor]"
notifies :start, "service[razor]"
end

service "razor" do
provider Chef::Provider::Service::Upstart
supports :status => true, :restart => true, :reload => false
action [ :enable, :start ]
end
end
1 change: 1 addition & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
include_recipe 'razor::_nodejs'
include_recipe 'razor::_ruby_from_package'
include_recipe 'razor::_app'
include_recipe 'razor::_service'
include_recipe 'razor::_add_images'
14 changes: 14 additions & 0 deletions templates/default/razor.upstart.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
description "Razor"
author "Guilhem Lettron <guilhem@lettron.fr>"

start on runlevel [2345]
stop on runlevel [!2345]

respawn # respawn the service if it dies

#script
# export RBENV_ROOT="/opt/rbenv" # set required rbenv variable
# exec ${RBENV_ROOT}/bin/rbenv exec <%= ::File.join(@install_path, "bin", "razor_daemon.rb") %> start --ontop
#end script

exec <%= ::File.join(@install_path, "bin", "razor_daemon.rb") %> start --ontop