Deploy Sockethub from the npm package
This is currently 3.1.4 and is set as an attribute. The recipe is very simple now, it installs the npm package, and the systemd service runs /usr/bin/sockethub and sets the environment variables Closes #145
This commit is contained in:
@@ -39,47 +39,33 @@ user "sockethub" do
|
||||
shell "/bin/bash"
|
||||
end
|
||||
|
||||
path_to_deploy = "/opt/sockethub"
|
||||
application path_to_deploy do
|
||||
owner "sockethub"
|
||||
group "sockethub"
|
||||
|
||||
git do
|
||||
user "sockethub"
|
||||
group "sockethub"
|
||||
repository 'https://github.com/sockethub/sockethub.git'
|
||||
revision node['sockethub']['revision']
|
||||
end
|
||||
|
||||
npm_install do
|
||||
user "sockethub"
|
||||
end
|
||||
|
||||
execute "systemctl daemon-reload" do
|
||||
command "systemctl daemon-reload"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
template "/lib/systemd/system/sockethub_nodejs.service" do
|
||||
source 'nodejs.systemd.service.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
user: "sockethub",
|
||||
group: "sockethub",
|
||||
app_dir: path_to_deploy,
|
||||
entry: "/usr/bin/node /usr/bin/npm start",
|
||||
environment: { 'DEBUG' => '*',
|
||||
'PORT' => node['sockethub']['port'],
|
||||
# Use the second database (index starts at 0)
|
||||
'REDIS_URL' => "redis://localhost:6379/1" }
|
||||
)
|
||||
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
||||
notifies :restart, "service[sockethub_nodejs]", :delayed
|
||||
end
|
||||
|
||||
service "sockethub_nodejs" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
npm_package "sockethub" do
|
||||
version node['sockethub']['version']
|
||||
end
|
||||
|
||||
execute "systemctl daemon-reload" do
|
||||
command "systemctl daemon-reload"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
template "/lib/systemd/system/sockethub_nodejs.service" do
|
||||
source 'nodejs.systemd.service.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
user: "sockethub",
|
||||
group: "sockethub",
|
||||
entry: "/usr/bin/sockethub",
|
||||
environment: { 'DEBUG' => '*',
|
||||
'PORT' => node['sockethub']['port'],
|
||||
# Use the second database (index starts at 0)
|
||||
'REDIS_URL' => "redis://localhost:6379/1" }
|
||||
)
|
||||
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
||||
notifies :restart, "service[sockethub_nodejs]", :delayed
|
||||
end
|
||||
|
||||
service "sockethub_nodejs" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user