67 lines
1.4 KiB
Ruby
67 lines
1.4 KiB
Ruby
#
|
|
# Cookbook Name:: sockethub
|
|
# Recipe:: default
|
|
#
|
|
# Copyright 2015-2017, Kosmos
|
|
#
|
|
# All rights reserved - Do Not Redistribute
|
|
#
|
|
|
|
include_recipe 'kosmos-nodejs'
|
|
include_recipe 'kosmos-redis'
|
|
|
|
group "sockethub" do
|
|
gid 7625
|
|
end
|
|
|
|
user "sockethub" do
|
|
comment "sockethub user"
|
|
uid 7625
|
|
gid 7625
|
|
manage_home true
|
|
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'] }
|
|
)
|
|
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
|
notifies :restart, "service[sockethub_nodejs]", :delayed
|
|
end
|
|
|
|
service "sockethub_nodejs" do
|
|
action [:enable, :start]
|
|
end
|
|
end
|