lostinplace
lostinplace

Reputation: 1518

chef service start_command not working

I'm trying to launch a node process as a service using forever, but the configuration is not working correctly. What's wrong with it?

execute "npm install -g forever"

restart_command_string = "forever restart /#{studio_server_folder}/#{studio_server_script}"
reload_command_string = "forever restart /#{studio_server_folder}/#{studio_server_script}"
start_command_string = "forever start /#{studio_server_folder}/#{studio_server_script}"
stop_command_string = "forever stop /#{studio_server_folder}/#{studio_server_script}"
status_command_string = "if [ $(forever list | grep -c \"studio-server\") -gt 0 ]; then echo 1; else echo 0; fi"


# execute "if [ $(forever list | grep -c \"studio-server\") -gt 0 ]; then #{restart_command_string}; else #{start_command}; fi"

service 'studio-server' do
  supports :status => true, :restart => true, :reload => true

  start_command start_command_string
  reload_command reload_command_string
  stop_command stop_command_string
  status_command status_command_string
  restart_command restart_command_string
  action [:start]

end

execute 'service --status-all >> /servicestatus'

Upvotes: 1

Views: 746

Answers (1)

coderanger
coderanger

Reputation: 54211

That status command isn't a command, it is a fragment of bash script and thus is unlikely to be working. In general I would highly recommend using a real service manager like supervisord or systemd.

Upvotes: 1

Related Questions