Class: Cany::Recipes::WebServer

Inherits:
Cany::Recipe show all
Defined in:
lib/cany/recipes/web_server.rb

Direct Known Subclasses

Thin

Instance Attribute Summary

Attributes inherited from Cany::Recipe

#inner, #spec

Instance Method Summary collapse

Methods inherited from Cany::Recipe

#build, #clean, #exec, from_name, #initialize, #install, #install_content, #install_dir, #install_link, register_as, #rmtree, #ruby_bin

Constructor Details

This class inherits a constructor from Cany::Recipe

Instance Method Details

#binaryObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cany/recipes/web_server.rb', line 4

def binary
  File.open File.join('debian', "#{spec.name}.upstart"), 'w' do |f|
    f.write "description  \"#{spec.description}\"\n"

    f.write "start on filesystem or runlevel [2345]\n"
    f.write "stop on runlevel [!2345]\n"

    f.write "respawn\n"
    f.write "respawn limit 10 5\n"
    f.write "umask 022\n"

    f.write "chdir /usr/share/#{spec.name}\n"

    f.write "pre-start script\n"
    f.write "\tmkdir -p /var/run/#{spec.name}\n"
    f.write "\tchown www-data /var/run/#{spec.name}\n"
    f.write "end script\n"

    f.write "exec su www-data --shell /usr/bin/#{spec.name} -- #{launch_command}\n"
  end
  inner.binary
end