0

I have added a service unit in Ubuntu 16.04:

[Unit]
Description=seaweedfs
After=network.target

[Service]
User=root
ExecStart=/root/work/bin/weed -v=0 volume -mserver=18.21.1.150:9333 -ip=8.9.4.9 -dir=/storage -max=2270 -images.fix.orientation=false -pulseSeconds=1

Everything is working fine. But I want to know if the process has been started or not. Or if it stopped, then I want to see some output as it has been stopped.

Right now am doing service seaweedfs start. It starts but doesn't show any message. I want to add some useful messages to it on start or stop.

Will be thankful for any help :)

Zanna
  • 70,465
  • What about systemctl start seaweedfs? – muru Nov 04 '16 at 06:19
  • Sorry I didnt get? This is what i have asked. I have asked how can I add some information about start and stop in file? – Junaid Farooq Nov 04 '16 at 06:23
  • Ah, yes. Sorry. Usually, you don't, since systemd will swallow any and all output from starting a unit and send it to the logs. You will probably have to write a wrapper around service (or call service seaweedfs status immediately after). – muru Nov 04 '16 at 06:25
  • Yeah tahnks.. But couldn't it be a post and pre script type thing? to echo something if it started or not? – Junaid Farooq Nov 04 '16 at 06:29
  • There are the ExecStartPost and ExecStopPost options, but as I said, the output will go to the logs. – muru Nov 04 '16 at 06:32
  • Okay thanks,, Can you tell how can i used these things in service unit start on filesystem or runlevel [2345] stop on runlevel [!2345] limit nofile 1000000 1000000 – Junaid Farooq Nov 04 '16 at 06:34
  • This duplicates http://askubuntu.com/questions/792940/ – JdeBP Nov 09 '16 at 20:45

1 Answers1

0

You can check sudo netstat -nlutp | grep weed to see if the port assigned in your .service file, (9333 in this case) opened.

If you see like this, the service may started

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 192.168.0.2:8081        0.0.0.0:*               LISTEN      25878/./weed
tcp6       0      0 :::9333                 :::*                    LISTEN      1244/./weed
muru
  • 197,895
  • 55
  • 485
  • 740