Writing a very simple Daemon in Rust

71 points cybermethhead

Hello everyone, a few days ago I watched a video called writing your own daemon in C which lead me to try to write one on my own in Rust. I am by no means a Rustacean, nor an expert. Just an average programmer curious about writing a service in Rust.

I call the Daemon birth-hound. It is as the name suggests a daemon which notifies you if it's anyone's birthday (it can be used for notifying you about other important dates as well!). It keeps track of a CSV file which includes the birth date and the person's name. Naturally the daemon checks for all the dates and then notifies using libnotify crate.

Here are my questions :

  1. Is this too simple of an idea to be written as a daemon, as daemon's do consume cpu and ram resources

  2. Is there another approach to do this? I discovered that systemd uses .timer which is used for scheduling programs, so instead of writing a long running process which actually excutes instructions once in a day, you could write a .timer file and in it tell it to execute the rust file to do the checking at 11:59pm everyday

  3. Do you think it is a good idea to write it in a cli style app wherein the user can do a birth-hound start or birth-hound stop to start and stop the daemon to their wish

  4. I would access the CSV file using File IO obviously, but should I asc users to create their own CSV file and ask them to manually enter it's path into the src code or should I provide them with a CSV myself, if it's the latter, how should I go about it?

That's all the questions I have for now. Feel free to ask me more questions if you have any.

Any sort of advise or guidance would be of great help!!!
Thank you in advance and apologies if this seems to be noob questions
I literally downloaded Rust two days ago and am trying to read the docs and figure my way out