Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netdata service: init #20183

Merged
merged 1 commit into from Jan 20, 2017
Merged

netdata service: init #20183

merged 1 commit into from Jan 20, 2017

Conversation

womfoo
Copy link
Member

@womfoo womfoo commented Nov 5, 2016

Motivation for this change

make netdata easier to enable

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@womfoo, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @joachifm and @offlinehacker to be potential reviewers.

};

configText = mkOption {
type = types.nullOr types.str;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be made type = types.line; with "" as default. Removing nullOr save the need for if isNull cfg.configText then "" else " later, and types.lines will provide better value merging in case the option is defined multiple times.

@womfoo
Copy link
Member Author

womfoo commented Nov 6, 2016

Thanks @ericsagnes! It just got back to me that netdata works with empty configs.

Rebased changes with your feedback.

@womfoo
Copy link
Member Author

womfoo commented Nov 7, 2016

Rebased changes to address conflict in ids.nix

@@ -278,6 +278,7 @@
postgrey = 258;
hound = 259;
leaps = 260;
netdata = 261;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me like the data generated by this service is highly machine specific and that ownership will be eventually consistent, given the preStart script. Please consider dynamic uid allocation.

@womfoo
Copy link
Member Author

womfoo commented Nov 8, 2016

@joachifm thanks for reviewing this. I've updated the commit to use dynamic uids.

Copy link
Contributor

@joachifm joachifm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, added a couple of minor points for you to consider.

wantedBy = [ "multi-user.target" ];
preStart = concatStringsSep "\n" (map (dir: ''
test -d ${dir} || {
echo "creating directory for netdata in ${dir}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you could do mkdir -vp which will print a message iff the directory is created.

"/var/log/netdata"
"/var/lib/netdata" ]);
serviceConfig = {
Type = "simple";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type = "simple" is the default.

in {
options = {
services.netdata = {
enable = mkEnableOption "netdata";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe mkEnableOption has fallen out of favour so probably shouldn't be used for new code.

@womfoo womfoo force-pushed the init/netdata-service branch 3 times, most recently from 728720e to 6ac08e5 Compare November 9, 2016 04:06
@womfoo
Copy link
Member Author

womfoo commented Nov 9, 2016

Rebased and tested OK

preStart = concatStringsSep "\n" (map (dir: ''
test -d ${dir} || {
echo "creating directory for netdata in ${dir}"
mkdir -vp ${dir}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you now should be able to remove the echo and enclosing conditional; mkdir -vp should achieve the same effect.

Copy link
Member Author

@womfoo womfoo Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased. Thanks!

after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
preStart = concatStringsSep "\n" (map (dir: ''
test -d ${dir} || mkdir -vp ${dir}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could even remove the test because mkdir -p doesn't fail if the directory already exists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks @fpletz

Copy link
Member

@LnL7 LnL7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for this, thought it was merged it.

@LnL7 LnL7 merged commit 2b2b0b5 into NixOS:master Jan 20, 2017
@womfoo womfoo deleted the init/netdata-service branch April 30, 2017 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants