2

I wanted to run my server when connection to terminal is closed but i cannot do it.

Whenever i try to sudo start myconf_file it returns with start: command not found or even sudo initctl start myconf_file with initctl: command not found.

I am trying to use upstart for Golang .exe based on this file:

description "start and stop the go program 'my-project'"

start on filesystem or runlevel [2345]
stop on runlevel [!2345]

env USER='ubuntu'
env APP_DIR='/home/ubuntu/go/src/github.com/your-username/your-project-name/'
env APP_EXEC='your-project-name'

exec start-stop-daemon --start --chuid ${USER} --chdir ${APP_DIR} --exec ${APP_DIR}${APP_EXEC}

File is placed in /etc/init.d/folder.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
HowToGo
  • 327
  • 1
  • 4
  • 14

1 Answers1

0

There was no need for a script/startup. Did it using setsid. So sudo setsid ./NameOfTheExe.

Then if the process has to be killed pidof and kill can be used.

pidof NameOfTheExe

and then as id of the process shows, for example "1871"

sudo kill 1871
HowToGo
  • 327
  • 1
  • 4
  • 14