Install and monitor skypool's Nimiq client via ansible playbook, systemd and ruby & cron
Personally, i believe that the Litecoin and Ethereum projects have been so far able to generate a strong economy around them, however, projects like Nimiq definitely convince me in terms of usability and simplicity approach to the user.
I am considering Ubuntu 16.04 as base operating system.
The playbook does the following things:
- Install the necessary dependencies -
ruby-devfor ruby 2.3, ruby gem package manage -
unzipto handle the release file from github
- Create a specific user
nimiqand a program directory
- Download and unpack the release file from github under a version-specific directory below the program directory
- Create skypool client configuration file according to your demands and with your wallet address
- Create a systemd unit file, start the skypool client as a service and enable restart on reboot
- Create a status checker that uses the skypool api to check the worker’s online/offline status
- Create a crontab entry for the root user to run the status checker every ten minutes
The cron entry running every 10 minutes is a tradeoff on how brittle the online/offline check delay currently is experienced by me through the skypool site. Presumably skypool does not have a real heartbeat check towards the worker but assumes that the worker is online when it receives results from it, and subsequently assumes the worker to be offline if it does not (most pools in the cryptocurrency world work like that). That means in terms of perfect time period between checks, your mileage may vary.
The service runs currently under the user
nimiq, hence a non-privileged user of the system. However, the systemd daemon used is the one from
root. Hence only the root user can restart the nimiq service. For this reason, the cron entry is registered through the root user. If you want to be able to use the nimiq user to restart the nimiq service, you have to run a systemd daemon based on the nimiq user. I have successfully done that for another service playbook, and I might add this information in the future, if demand is voiced.
Find below the full gist as published on github. Full gist here.