How to run seaweedFS as a daemon?

1k views Asked by At

Started and tested a multi-server seaweedFS setup as below which is working great:

./weed server -dir=/VolA,/VolB -s3 -s3.config=weed.json -s3.port=9001 -master.defaultReplication="010" -master.peers=ip1:9333,ip2:9333,ip3:9333 -ip=ip1 -dataCenter=ABC -rack=A -volume.max=100
./weed server -dir=/VolA,/VolB -s3 -s3.config=weed.json -s3.port=9001 -master.defaultReplication="010" -master.peers=ip1:9333,ip2:9333,ip3:9333 -ip=ip2 -dataCenter=ABC -rack=B -volume.max=100
./weed server -dir=/VolA,/VolB -s3 -s3.config=weed.json -s3.port=9001 -master.defaultReplication="010" -master.peers=ip1:9333,ip2:9333,ip3:9333 -ip=ip3 -dataCenter=ABC -rack=C -volume.max=100

However, I don't see any documentation on how to keep seaweedFS running as a daemon. I.e.: currently I'm running weed in a remote shell. Closing the shell shutsdown weed.

Any pointers much appreciated

1

There are 1 answers

0
Geert-Jan On BEST ANSWER

Solved it by hand-rolling a systemd service.

For each node do: (obviously, replace with your own weed specific commands)

# 1. Move `weed` to some directory the startup service can access. I used `/usr/local/bin/weed/`. Include `weed` and `weed.json` in that directory (ymmv) 


mkdir /usr/local/bin/weed
mv weed /usr/local/bin/weed/weed
mv weed.json /usr/local/bin/weed/weed.json


# 2. Create a systemd service config: 

cat > /etc/systemd/system/seaweedmaster.service <<EOM

[Unit]
Description=SeaweedFS Server
After=network.target

[Service]
Type=simple
User=root
Group=root

ExecStart=/usr/local/bin/weed/weed server -dir=/VolA,/VolB -s3 -s3.config=weed.json -s3.port=9001 -master.defaultReplication="010" -master.peers=ip1:9333,ip2:9333,ip3:9333 -ip=ip1 -dataCenter=ABC -rack=A -volume.max=100
WorkingDirectory=/usr/local/bin/weed/
SyslogIdentifier=seaweedfs-master

[Install]
WantedBy=multi-user.target
EOM


# 3. Reload, enable and start 

sudo systemctl daemon-reload
sudo systemctl enable seaweedmaster
sudo systemctl start seaweedmaster



# 4. logging the output, one of many options: 

journalctl -u seaweedmaster.service -b --no-pager