This will stop systemd from thinking the closedown has failed. But, as you want to give your users a couple of minutes before closing the server completely, you are going to push the default up to three minutes. Anything longer, and systemd will force the service to close down and report a failure. The default time out value is round about 90 seconds. The TimeoutStopSec directive pushes up the time before systemd bails on shutting down the service. Next up, you have a block of commands that close down the server. Although the script shown above is to all practical effects only one line long, remember you can’t have a line with pipes and redirections as a systemd unit argument, so you have to wrap it in a script.įor the record, there is also an ExecStartPre directive for things you want to execute before starting the service proper. In this case, you run a custom script, mtsendmail (see below), that sends an email to your friends telling them that the server is up.Įcho $1 | mutt -F /home//.muttrc -s "$2" can use Mutt, a command-line email client, to shoot off your messages. You can use this directive for anything you want to run right after the main application starts. First, there’s the ExecStartPost directive. Let’s jazz it up a bit by having it send out emails to the players, alerting them when the server becomes available and warning them when it is about to be turned off:ĮxecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" "Minetest Starting up"ĮxecStop= /home//bin/mtsendmail.sh "Off to bed. As it stands, however, your service is still not much better than running the server directly. In the previous article, we showed how to create a systemd service that you can run as a regular user to start and stop your game server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |