I am trying to get Monit / init.d scripts running on a few different servers, and for a few different processes on Ubuntu servers.
- Trying to get Sphinx to start on reboot, and to work with Monit
- Trying to get Elixir/Phoenix mix phx.server to start on reboot and work with Monit
- When I run monit -t I see no errors
For elixir:
- When logged in as deploy user role, I manually run ./etc/init.d elixir start – the process starts just fine
- When logged in as deploy user role I manually run sudo monit start elxir but nothing happens...
- When I reboot the machine the application is not started
- I am attempting to log result of the init.d script, but I see no output
For searchd:
When logged in as deploy user role, I manually run ./etc/init.d sphinx start – the process starts just fine
When logged in as deploy user role I manually run sudo monit start sphinx but nothing happens...
When I reboot the machine the application is not started
I am attempting to log result of the init.d script, but I see no output
The init.d scripts are executable
I’ve tried this command which I read may ensure that the script is registered to run on reboot: sudo update-rc.d start_sphinx defaults
Example Elixir monit script:
example monit script:
check process api matching "mix phx.server"
start program = "/etc/init.d/elixir start" as uid deploy and gid deploy
stop program = "/etc/init.d/elixir stop" as uid deploy and gid deploy
Example Elixir init.d script:
#!/bin/bash
# chkconfig: 2345 20 80
# description: Elixir API
# Source function library.
#. /etc/init.d/functions
start() {
cd /home/deploy/apps/api && PORT=8888 MIX_ENV=prod elixir --erl "-detached" -S mix phx.server > /home/deploy/elixir_init_d_start.log 2>&1
}
stop() {
pkill -f 'mix phx.server'
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
# code to check status of app comes here
# example: status program_name
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
exit 0