takama/daemon

service can not start

Opened this issue · 9 comments

I follow the following steps to do, but can not start:
go build myservice.go
./myservice install
Install My Echo Service: [ OK ]
./myservice start
Starting My Echo Service: [FAILED]
Error: exit status 5

system is ubuntu.16.04

I cant verify this in nearest time, but maybe somebody check who use ubuntu 16.04

I get the same error. On raspberry pi (debian jessie) I get error code 6.

$ go build
$ sudo ./myservice install
Install My Echo Service: [ OK ]
$ sudo ./myservice start
Starting My Echo Service: [FAILED]
Error: exit status 6

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

$ cat /proc/version
Linux version 4.9.11-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #971 SMP Mon Feb 20 20:44:55 GMT 2017

It was solved by removing the following two lines in /etc/systemd/system/myservice.service:

Requires=dummy.service
After=dummy.service

@hawavisi
I get the same env with you。
Do it your way:
./myservice start sucess,but can't auto restart after myservice abort.
Can you see the same question?

@hawavisi @takama
[letian@inf example]$ sudo ./myservice install
[sudo] password for letian:
Install My Echo Service: [ OK ]
[letian@inf example]$ sudo ./myservice status
Service is stopped
[letian@inf example]$ sudo ./myservice start
Starting My Echo Service: [FAILED]
Error: exit status 5
[letian@inf example]$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

For those who see the same issue. Try to remove dummy.service in the line

var dependencies = []string{"dummy.service"}

It might be helpful.

@threeearcat I removed dummy.service and it works well on ubuntu 16.04. Thank you

I get the same error
cat /etc/os-release

NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

./myservice install
Install My Echo Service: [FAILED]
Error: Service has already been installed

/myservice remove
Removing My Echo Service: [FAILED]
Error: exit status 1

./myservice stop
Stopping My Echo Service: [FAILED]
Error: Service has already been stopped

i solved this way..

  1. change your code.
    srv, err := daemon.New(name, description, dependencies...)
    =>
    srv, err := daemon.New(name, description)
  2. remove service
  3. install service
  4. start service
  5. ok... good.!