1

I have checked again and again on terminal and ./go.sh both working but not able to start as service. I know i am doing it wrong but not sure what.

/root/go.sh

#!/usr/bin/env bash
export PATH=/sbin:/usr/sbin:/bin:/usr/bin

/root/goweb/bin/echoip -t=/root/goweb/bin/index.html

And


/lib/systemd/system/goweb.service

[Unit]
Description=goweb

[Service]
Type=forking
Restart=always
RestartSec=5s
ExecStart=/root/go.sh

[Install]
WantedBy=multi-user.target

I dont know what happen now the service starting and stopped and starting and stopped

Here is the status

goweb.service - goweb
   Loaded: loaded (/lib/systemd/system/goweb.service; enabled; vendor preset: en
   Active: activating (start) since Sun 2020-01-19 19:39:52 UTC; 36s ago
Cntrl PID: 1259 (bash)
    Tasks: 6 (limit: 1151)
   CGroup: /system.slice/goweb.service
           ├─1259 bash /root/go.sh
           └─1268 /root/goweb/bin/echoip -t=/root/goweb/bin/index.html

Jan 19 19:39:52 ip systemd[1]: goweb.service: Service hold-off time over, schedu
Jan 19 19:39:52 ip systemd[1]: goweb.service: Scheduled restart job, restart cou
Jan 19 19:39:52 ip systemd[1]: Stopped goweb.
Jan 19 19:39:52 ip systemd[1]: Starting goweb...
Jan 19 19:39:52 ip go.sh[1259]: echoip: Listening on http://0.0.0.0:8080
Shimul D
  • 111
  • 3
  • check this https://www.devdungeon.com/content/creating-systemd-service-files for how to create a Service file correctly – Talal Al-Khalifa Jan 19 '20 at 21:03
  • I do not use the equal sign in passing echoip arguments: *echoip -f /path/to/some/file...*. Take a look at the Wiki, https://github.com/mpolden/echoip/wiki/Running-Echo-IP-in-a-docker-with-Caddy-Reverse-proxying-with-Certs-from-Let's-encrypt – MariusMatutiae Aug 06 '20 at 06:16

1 Answers1

0

add to top of your script go.sh

export PATH=/sbin:/usr/sbin:/bin:/usr/bin

If there are more paths needed add them above or add the full path to any script or command, you want to execute on your script.

Talal Al-Khalifa
  • 668
  • 5
  • 12