I'm using the following script in /etc/init/my-project.conf
on my AWS instance.
description "start and stop the go program 'my-project'"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
env USER='ec2-user'
env APP_DIR='/home/ec2-user/go/src/bitbucket.com/xxx/my-project/'
env APP_EXEC='my-project'
exec start-stop-daemon —start —chuid ${USER} —chdir ${APP_DIR} —exec ${APP_DIR}${APP_EXEC}
service my-project start
command gives unrecognized service
error. sudo start my-project
starts a process which is not my project. When I run sudo status my-project
command I get my-project stop/waiting
. I couldn't find what I'm doing wrong.
In the path /home/ec2-user/go/src/bitbucket.com/xxx/my-project/
there is an executable file named my-project
. So basically /home/ec2-user/go/src/bitbucket.com/xxx/my-project/my-project
runs the executable.