I wrote simple systemd service-file goserver.service
:
[Unit]
Description=Goserver
[Service]
ExecStart=/usr/bin/go run /home/denis/goserver/index.go
[Install]
WantedBy=multi-user.target
But when I try to run service and get status:
$ sudo systemctl status goserver.service
I get error:
мар 02 12:28:04 DV go[13627]: home/denis/goserver/index.go:6:2: cannot find package "gopkg.in/mgo.v2" in any of:
мар 02 12:28:04 DV go[13627]: /usr/lib/go-1.6/src/gopkg.in/mgo.v2 (from $GOROOT)
мар 02 12:28:04 DV go[13627]: ($GOPATH not set)
But $GOPATH
is set with export
command:
$ export GOPATH="/home/denis/goserver/"
$ ls $GOPATH
goserver.log index.go pkg src templates
And this command from command-line works fine:
$ /usr/bin/go run /home/denis/goserver/index.go
But if I use systemd service it doesn't work.
How can I run systemd service with detected $GOPATH
? (without binary file created by command go build...
)