What's the purpose of these directives inside redis unit file? Are they needed?

September 28, 2018 1.3k views
Ubuntu 16.04 Redis Ubuntu

I am asking because in this redis tutorial link the author does not mention these.

ExecStartPre=-/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d
ExecStartPost=-/bin/run-parts --verbose /etc/redis/redis-server.post-up.d
ExecStop=-/bin/run-parts --verbose /etc/redis/redis-server.pre-down.d
ExecStop=/bin/kill -s TERM $MAINPID
ExecStopPost=-/bin/run-parts --verbose /etc/redis/redis-server.post-down.d


# redis-server writes its own config file when in cluster mode so we allow
# writing there (NB. ProtectSystem=true over ProtectSystem=full)

In unit description, can we write whatever word we want or must be some directive.

Description=Advanced key-value store
2 Answers

Your systemd service seems more comprehensive compared to the one you’ve linked. It’s a good thing. Generally, the more elaborate your service file the more stable the service is going to be. Not always but generally speaking.

So to answer your question, they’re not absolutely necessary but you’re better off with them than without. You’re also free to describe your Unit however you want. It’s free form and isn’t a directive.

  • unixynet, thanks for the answer.

    I wanted you to ask also about:
    In my systemd file I have 3 ExecStop commands

    ExecStop=-/bin/run-parts --verbose /etc/redis/redis-server.pre-down.d
    ExecStop=/bin/kill -s TERM $MAINPID
    ExecStopPost=-/bin/run-parts --verbose /etc/redis/redis-server.post-down.d

    But, in the tutorial that I have linked there is 1 ExecStop command and it is not the same. ExecStop=/usr/local/bin/redis-cli shutdown

    Do those 3 ExecStop commands interfere and cause some problem in the future or not, or should I replace with the new one. Or just simply add a fourth commands that it is suggested in the tutorial?

Yes, they are not necessary.

Have another answer? Share your knowledge.