66 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| #
 | |
| # Cookbook Name:: sockethub
 | |
| # Recipe:: default
 | |
| #
 | |
| 
 | |
| include_recipe 'redisio::default'
 | |
| include_recipe 'redisio::enable'
 | |
| include_recipe 'kosmos-nodejs'
 | |
| 
 | |
| user  = "sockethub"
 | |
| group = "sockethub"
 | |
| entry = "/usr/bin/sockethub"
 | |
| 
 | |
| group group do
 | |
|   gid 7625
 | |
| end
 | |
| 
 | |
| user user do
 | |
|   comment     "sockethub user"
 | |
|   uid         7625
 | |
|   gid         7625
 | |
|   manage_home true
 | |
|   shell       "/bin/bash"
 | |
| end
 | |
| 
 | |
| npm_package "sockethub" do
 | |
|   version node['sockethub']['version']
 | |
| end
 | |
| 
 | |
| execute "systemctl daemon-reload" do
 | |
|   command "systemctl daemon-reload"
 | |
|   action :nothing
 | |
| end
 | |
| 
 | |
| environment_variables = {
 | |
|   'PORT' => node['sockethub']['port'],
 | |
|   # Use the second database (index starts at 0)
 | |
|   'REDIS_URL' => "redis://localhost:6379/1"
 | |
| }
 | |
| unless node['sockethub']['debug_logs'].nil?
 | |
|   environment_variables['DEBUG'] = node['sockethub']['debug_logs']
 | |
| end
 | |
| 
 | |
| environment = environment_variables.map{|k, v| "'#{k}=#{v}'"}.join(' ')
 | |
| 
 | |
| systemd_unit "sockethub_nodejs.service" do
 | |
|   content <<-EOF
 | |
| [Unit]
 | |
| Description=Start sockethub
 | |
| Requires=redis@6379.service
 | |
| After=redis@6379.service
 | |
| 
 | |
| [Service]
 | |
| ExecStart=#{entry}
 | |
| User=#{user}
 | |
| Group=#{group}
 | |
| Environment=#{environment}
 | |
| Restart=always
 | |
| 
 | |
| [Install]
 | |
| WantedBy=multi-user.target
 | |
|   EOF
 | |
|   triggers_reload true
 | |
|   action [:create, :enable, :start]
 | |
| end
 |