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

nginx: add custom options #48875

Merged
merged 1 commit into from Oct 28, 2018
Merged

nginx: add custom options #48875

merged 1 commit into from Oct 28, 2018

Conversation

Izorkin
Copy link
Contributor

@Izorkin Izorkin commented Oct 23, 2018

Motivation for this change

Add custom options:

  • logError - Allow to change the location of the default log. For example, redirect to syslog.
  • preStart - Allow running custom scripts. A way with "systemd.services.nginx.preStart" does not work well.
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • 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/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

'';
description = "
Shell commands executed before the service's nginx is started.
";
Copy link
Member

Choose a reason for hiding this comment

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

What is the motivation for that? Can you provide an example?

Copy link
Contributor Author

@Izorkin Izorkin Oct 23, 2018

Choose a reason for hiding this comment

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

example script-pre-nginx-start, generated with systemd.services.nginx.preStart

mkdir -p /var/spool/logs
chmod 700 /var/spool
chown -R web:web /var/spool
/nix/store/zg5sc4sby91mp4xvd29s9f1i7yc67va3-nginx-1.14.0/bin/nginx -c /nix/store/vjlj3ak74wb0vpavgwr911a40aqhcc63-nginx.conf -p /var/data/web/12000/spool -t
chown web:web /var/data/web

Command "chown web:web /var/data/web" not worked - error - Operation not permitted

Copy link
Member

@Mic92 Mic92 Oct 23, 2018

Choose a reason for hiding this comment

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

How does the preStart option help you here? You would still run into the same permission problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no problems in this case. Normal worked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

everything above the command
/nix/store/zg5sc4sby91mp4xvd29s9f1i7yc67va3-nginx-1.14.0/bin/nginx
normal worked.

};

daemon = mkOption {
default = false;
Copy link
Member

Choose a reason for hiding this comment

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

If it started in deamon mode does the systemd service not need to change to forking too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated PR.

type = types.bool;
description = "
Determines whether nginx should become a daemon. Mainly used
during development.
Copy link
Member

Choose a reason for hiding this comment

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

Mainly used during development Can you elaborate on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Izorkin
Copy link
Contributor Author

Izorkin commented Oct 23, 2018

Updated PR, daemon mode not worked.

@Mic92
Copy link
Member

Mic92 commented Oct 28, 2018

@GrahamcOfBorg test nginx

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: tests.nginx

Partial log (click to expand)

webserver: exit status 1
syncing
webserver: running command: sync
webserver: exit status 0
test script finished in 12.07s
cleaning up
killing webserver (pid 631)
vde_switch: EOF on stdin, cleaning up and exiting
vde_switch: Could not remove ctl dir '/build/vde1.ctl': Directory not empty
/nix/store/xqi22bvarzm6lrk115483nfhhhhhyi15-vm-test-run-nginx

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: tests.nginx

Partial log (click to expand)

webserver: exit status 1
syncing
webserver: running command: sync
webserver: exit status 0
test script finished in 145.51s
cleaning up
killing webserver (pid 600)
vde_switch: EOF on stdin, cleaning up and exiting
vde_switch: Could not remove ctl dir '/build/vde1.ctl': Directory not empty
/nix/store/nwqanl66s87fvl42h696r5ncwgglb58c-vm-test-run-nginx

@Mic92 Mic92 merged commit eb70af1 into NixOS:master Oct 28, 2018
@Izorkin
Copy link
Contributor Author

Izorkin commented Oct 29, 2018

Thanks!

@Izorkin Izorkin deleted the nginx-prestart branch October 29, 2018 04:52
@Izorkin Izorkin mentioned this pull request Dec 5, 2018
10 tasks
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

3 participants