1

I am using upstart to start my golang application. I have my application folder structure like this,

   Web-app/
         /app
             main.go

I built the application

$cd /home/ec2-user/go/src/github.com/dineshappavoo/web-app/app/
$go build ./...

It generated app [executable file] under app folder as app.

And placed the web-app.conf in /etc/init/ folder. Here is the web-app.conf content,

#Web app upstart script
description "start and stop web app"

start on (net-device-up
and local-filesystems
and rullevel [2345])

stop on runlevel [016]

respawn
respawn limit 5 30

console output   

script
    chdir /home/ec2-user/go/src/github.com/dineshappavoo/web-app/app
    exec ./app
end script

When I tried sudo initctl list, it lists the process as stop/waiting. And I tried to start the process

$sudo initctl start web-app

It shows the process as start/running. But it is not started.

I checked the /var/log/messages logs. It shows,

init: web-app main process (18740) terminated with status 127

I couldn't start the process. I think there is some issue with the chdir. I tried different options for past two days but no luck. And I am fairly new to upstart. Could someone help me with this?

1

The exit status 127 means the command could not be found. Your problem is you are trying to use an upstart stanzas inside the script block so upstart is trying to execute it as a command, which does not exist. You should move it above the script block instead.

Also since you are only using exec in the script block you can remove it and just use exec.

#Web app upstart script
description "start and stop web app"

start on (net-device-up
and local-filesystems
and rullevel [2345])

stop on runlevel [016]

respawn
respawn limit 5 30

console output   

chdir /home/ec2-user/go/src/github.com/dineshappavoo/web-app/app
exec ./app

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.