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

Add uWSGI application server #5277

Merged
merged 2 commits into from
Feb 5, 2015
Merged

Add uWSGI application server #5277

merged 2 commits into from
Feb 5, 2015

Conversation

abbradar
Copy link
Member

For now only Python plugins are supported (I haven't used uwsgi for anything besides Python and have no idea of needed workarounds, environs and so on).

@domenkozar
Copy link
Member

We should probably support running more than one instance of uwsgi

@abbradar
Copy link
Member Author

Good idea. This should look better together with systemd's @-services, but I can't find any examples of starting several instances of it. Specifically, after defining systemd.services."uwsgi@", how do I start uwsgi@abc and uwsgi@def (given I have [ "abc" "def" ])? AFAIU, adding systemd.services."uwsgi@abc" would make a completely new service instead of using uwsgi@.

@prikhi
Copy link
Member

prikhi commented Dec 24, 2014

Have you looked into uwsgi's emperor mode:
http://uwsgi-docs.readthedocs.org/en/latest/Emperor.html

This just requires starting the uwsgi in --emperor mode and adding configurations or symlinks to a directory.

Let me know if I can help out in any way.

@abbradar
Copy link
Member Author

The emperor mode would already work with this, but multiple uwsgi instances would be simpler for end-user if they are statically known.
Unfortunately I have too many things to do now, so I've decided to resume work on this after New Year.

@abbradar
Copy link
Member Author

abbradar commented Jan 3, 2015

I've thought about this -- emperor mode and multiple systemd services implement the same thing, if one would describe everything in his configuration. If not, emperor mode can be more flexible, as we can state a directory and add or remove services from it. If emperor mode would be enough for everyone, we can leave this as a single systemd service -- are there any usecases where multiple services would be better?

@prikhi
Copy link
Member

prikhi commented Jan 4, 2015

I use emporer mode whenever I need more than 1 uwsgi instance, but I only use it for python/django so I'm not sure about other scenarios.

@abbradar
Copy link
Member Author

abbradar commented Jan 9, 2015

So, @iElectric , do we need to support more than one instance or emperor mode should be enough? Maybe with some additional support from the module side?

@domenkozar
Copy link
Member

We could use emperor mode in NixOS itself, but I'd still have configuration for multiple services as a module.

@domenkozar
Copy link
Member

@abbradar we could touch that later, if you feel it's too much work.

@abbradar
Copy link
Member Author

Sorry for taking a long time, redone this -- now you can have arbitrary tree of emperors and their vassals with some sugar for configuration.
@iElectric That wasn't the problem, rather I was busy with a lot of other things ^_^

@matthiasbeyer
Copy link
Contributor

new-package label missing.

available = [ (pythonPlugin python2)
(pythonPlugin python3)
];
needed = builtins.filter (x: lib.any (y: x.name == y) plugins) available;
Copy link
Contributor

Choose a reason for hiding this comment

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

The indention of this line is more than of the other lines. Is there any reason for this?

Sorry for bitching around because of this, but this stuff makes reviewing hard, at least for me... 😏

Copy link
Member Author

Choose a reason for hiding this comment

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

This is codestyle oftenly used in Haskell, sorry for this. I'll fix this to stick to Nix standards.

@prikhi
Copy link
Member

prikhi commented Jan 20, 2015

So the "pure" way to use this with python would be to create a custom package for the project you're deploying and feed this to normal mode?

@abbradar
Copy link
Member Author

@prikhi Sorry for taking a long to answer. No, you are supposed to set python2Packages or python3Packages (depends on what you want) to a function which takes a set with packages and returns a list with needed ones.

@abbradar
Copy link
Member Author

@matthiasbeyer I tried to make it look better, try this and please say what I can improve. And thanks for the criticism, in my opinion it is very important for the code to be structured as readable as possible!

@domenkozar
Copy link
Member

Might be a good idea to add an example configuration to documentation.

@abbradar
Copy link
Member Author

abbradar commented Feb 2, 2015

Added example and fixed a couple of bugs while at it; now emperor mode is properly tested, too.

@abbradar
Copy link
Member Author

abbradar commented Feb 4, 2015

Any further comments? I think of merging this tomorrow.

@prikhi
Copy link
Member

prikhi commented Feb 4, 2015

I don't understand the significance of having python2/3Packages be a function instead of a list, but my nix-fu is not too superb.

@abbradar
Copy link
Member Author

abbradar commented Feb 4, 2015

This is to enforce you to use Python packages of the same version as Python uWSGI was compiled with. Well, it's not enforcing you in reality (you can as well return your own evil package), but this way you wouldn't bother about version mismatches -- if uWSGI's Python changes, so will input to your function, and hence, versions of your packages.

@abbradar
Copy link
Member Author

abbradar commented Feb 4, 2015

You can look at it as a way for you to write

python2Packages = args: with args; [ pkg1 pkg2 ];

instead of

python2Packages =
  let args = pkgs.python2Packages.override {
    python = pkgs.uwsgi.python2;
    self = args;
  };
  in with args; [ pkg1 pkg2 ];

or (unsafe! we don't know if uwsgi was built with the same Python as default!)

python2Packages = with pkgs.python2Packages; [ pkg1 pkg2 ];

@domenkozar
Copy link
Member

:shipit:

abbradar added a commit that referenced this pull request Feb 5, 2015
Add uWSGI application server
@abbradar abbradar merged commit f35568e into NixOS:master Feb 5, 2015
@abbradar abbradar deleted the uwsgi branch February 5, 2015 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants