SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
nix-processmgmt: An experimental Nix-based
process manager-agnostic framework
Sander van der Burg
October 17, 2020
Sander van der Burg nix-processmgmt
Nix package manager: a powerful solution
Conveniently construct packages from source code and all its
required build-time dependencies
Build determinism.
Same hash code → (nearly) bit-identical build
Transparent binary deployments (by using substitutes)
Store multiple versions and variants safely next to each other
Thanks to the hash prefixes and the Nix store
Unprivileged user deployments
Multiple operating systems: Linux, macOS, FreeBSD, others
Sander van der Burg nix-processmgmt
Nix: development environments
We can conveniently install and use all kinds of packages without
interfering with the host system’s packages.
nix-shell example
$ python --version
Python 2.7.15
$ node --version
node: command not found
$ nix-shell -p python3 nodejs
$ python --version
Python 3.8.5
$ which python
/nix/store/z65l1jqvxa58zzwwa3bvglb6asj4y8cv-python3-3.8.5/bin/python
$ node --version
v12.18.4
$ which node
/nix/store/2w6ilfh7zmbz9zqvphgxinmbn3wdqa1b-nodejs-12.18.4/bin/node
Sander van der Burg nix-processmgmt
Nix package manager: deploying services?
Sander van der Burg nix-processmgmt
Nix package manager: not a service manager
Nix does not manage application services/processes’ life-cycles.
Sander van der Burg nix-processmgmt
Nix: service deployment integrations
There are sister projects that complement Nix with process manage-
ment:
NixOS. Generates systemd unit files to manage services.
Requires you to switch to a fully Nix-managed Linux
distribution.
nix-darwin. Generates launchd daemon configuration files.
Only works on macOS.
Sander van der Burg nix-processmgmt
Nix: service deployment integrations
Nix can also be used to augment other process management solu-
tions:
Docker. Docker uses a package manager in Dockerfiles for
the construction of images.
Nix can be used as a replacement for conventional package
managers.
Nix can be used to fully build Docker images.
Not always not a compelling use case for Nix beginners →
they typically download prebuilt images from Docker Hub.
Docker is built around Linux technologies (e.g. namespaces)
and deploys Linux software
Sander van der Burg nix-processmgmt
nix-processmgmt: A general solution complementing Nix
with process management
Sander van der Burg nix-processmgmt
nix-processmgmt: A general solution complementing Nix
with process management
Driven by Nix and the Nix expression language
Based on simple conventions: function definitions and an
attribute set with function invocations
Similar to how packages are organized in Nixpkgs
Works with process dependencies as well: the framework
arranges the ordering, if needed
Process-manager agnostic: Integrates with sysvinit scripts,
supervisord, systemd, launchd, bsdrc scripts, cygrunsrv
Even with systems that are not qualified as process managers:
disnix, docker
Sander van der Burg nix-processmgmt
nix-processmgmt: A general solution complementing Nix
with process management
Operating system agnostic: Works on NixOS, but it is not a
requirement
Conventional Linux distros, macOS, FreeBSD, Cygwin
Unprivileged user installations
A switch to disable creation of users, and changing user
permissions
No advanced concepts required, such as namespaces and
cgroups
The solution relies on conflict avoidance, rather than isolation
Sander van der Burg nix-processmgmt
Example: a simple web application system
Sander van der Burg nix-processmgmt
Packaging the webapp process (sysvinit, verbose)
{createSystemVInitScript, webapp, port ? 5000}:
createSystemVInitScript {
name = "webapp";
description = "Example web application";
environment.PORT = port;
activities = {
start = ’’
log_info_msg "Starting Example web application..."
loadproc ${webapp}/bin/webapp -D
evaluate_retval
’’;
stop = ’’
log_info_msg "Stopping Example web application..."
killproc ${webapp}/bin/webapp
evaluate_retval
’’;
restart = "$0 stop; sleep 1; $0 start";
status = "statusproc ${webapp}/bin/webapp";
};
runlevels = [ 3 4 5 ];
}
Sander van der Burg nix-processmgmt
Packaging the webapp process (sysvinit, declarative)
{createSystemVInitScript, webapp, port ? 5000}:
createSystemVInitScript {
name = "webapp";
process = "${webapp}/bin/webapp";
args = [ "-D" ];
runlevels = [ 3 4 5 ];
environment.PORT = port;
}
We can also specify the daemon that we want to manage, instead of
the activity implementations. Most sysvinit activities (start, stop,
restart, reload, status) can be inferred.
Sander van der Burg nix-processmgmt
Packaging the webapp process (systemd)
The following function composes a systemd unit instead of a
sysvinit script:
{createSystemdService, webapp, port ? 5000}:
createSystemdService {
name = "webapp";
Unit = {
Description = "Example web application";
};
Service = {
ExecStart = "${webapp}/bin/webapp";
Environment.PORT = port;
Type = "simple";
};
}
The framework contains many other process manager-
specific abstraction functions: createSupervisordProgram,
createLaunchdDaemon, createBSDRCScript etc.
Sander van der Burg nix-processmgmt
Packaging the webapp process (agnostic)
Process manager-agnostic abstraction of the webapp service:
{createManagedProcess, webapp, port ? 5000}:
createManagedProcess {
name = "webapp";
description = "Example web application";
process = "${webapp}/bin/webapp";
daemonArgs = [ "-D" ]; # For process managers that prefer daemons
environment.PORT = port;
overrides = {
sysvinit.runlevels = [ 3 4 5 ];
};
}
Invokes the required target-specific abstraction function, e.g.
createSystemVInitScript, createSystemdService
overrides override/augment process manager-specific
parameters
You can treat foreground processes and daemons separately,
for optimal user experience
Sander van der Burg nix-processmgmt
Instantiatable webapp processes
{createManagedProcess, webapp}:
{instanceSuffix ? "", instanceName ? "webapp${instanceSuffix}", port ? 5000}:
createManagedProcess {
name = instanceName;
inherit instanceName; # To ensure a unique PID file name
description = "Example web application";
process = "${webapp}/bin/webapp";
daemonArgs = [ "-D" ]; # For process managers that prefer daemons
environment.PORT = port;
overrides = {
sysvinit.runlevels = [ 3 4 5 ];
};
}
instanceName: ensures that the daemon command generates
unique PID file
Outer-function header: parameters that apply to all instances.
Inner-function header: instance parameters. A unique
combination ensures that multiple instances can co-exist.
Sander van der Burg nix-processmgmt
Composing process instances
{ pkgs ? import <nixpkgs> {}
, stateDir ? "/var" , forceDisableUserChange ? false, processManager}:
let constructors = import ./constructors.nix {
inherit pkgs stateDir forceDisableUserChange processManager;
}; in
rec {
webapp1 = rec { # First webapp instance
port = 5000;
dnsName = "webapp1.local";
pkg = constructors.webapp {
inherit port; instanceSuffix = "1";
};
};
webapp2 = rec { # Second webapp instance
port = 5001;
dnsName = "webapp2.local";
pkg = constructors.webapp {
inherit port; instanceSuffix = "2";
};
};
...
}
Sander van der Burg nix-processmgmt
Composing process instances
{ pkgs ? import <nixpkgs> {}
, stateDir ? "/var" , forceDisableUserChange ? false, processManager}:
let constructors = import ./constructors.nix {
inherit pkgs stateDir forceDisableUserChange processManager;
}; in
rec {
...
# Nginx with a config that redirects users to the appropriate webapp
# instance based on the virtual host header
nginx = {
pkg = constructors.nginxReverseProxyHostBased {
# Process dependencies used to set up redirections in nginx.conf
webapps = [ webapp1 webapp2 ];
port = 8080;
} {};
};
}
Sander van der Burg nix-processmgmt
Demo: deploying the system and using it
Deploy the process instances as sysvinit scripts:
$ nixproc-sysvinit-switch processes.nix
Open the first webapp instance (via the Nginx reverse proxy):
$ curl -H ’Host: webapp1.local’ http://localhost:8080
Open the second webapp instance (via the Nginx reverse proxy):
$ curl -H ’Host: webapp2.local’ http://localhost:8080
Sander van der Burg nix-processmgmt
Demo: all kinds of process manager integrations
Deploy as systemd units (in a user session):
$ nixproc-systemd-switch --user processes.nix
Deploy as supervisord programs (stateless):
$ nixproc-supervisord-deploy-stateless processes.nix
Deploy on FreeBSD as BSD rc scripts:
$ nixproc-bsdrc-switch processes.nix
Deploy as Docker containers per service (with shared Nix store and
host networking):
$ nixproc-docker-switch processes.nix
Sander van der Burg nix-processmgmt
Demo: screenshots
Sander van der Burg nix-processmgmt
Other features of nix-processmgmt
Automatic creation of users and groups (createCredentials
function)
nixproc-id-assign: Automated assignment of unique IDs
for TCP/UDP ports, UIDs, GIDs to process instances
Using Disnix as a process orchestrator (works on all platforms
where Nix/Disnix is supported)
Sander van der Burg nix-processmgmt
Combining nix-processmgmt with Disnix
We can use any process manager, do distributed deployment and
combine processes with non-process based services (e.g. Java web
applications in an Apache Tomcat container):
Sander van der Burg nix-processmgmt
Example services packaged for nix-processmgmt
HTTP/application servers:
Apache HTTP server
Nginx
Apache Tomcat
Database:
PostgreSQL
MariaDB/MySQL
MongoDB
InfluxDB
Misc:
Docker
Supervisord
svnserve
Sander van der Burg nix-processmgmt
Future work
Deploy containers with multiple processes (WIP)
Mutable service containers (WIP)
s6 / s6-rc backend
Work on a test strategy for services
Maybe write an RFC?
Sander van der Burg nix-processmgmt
Availability
https://github.com/svanderburg/nix-processmgmt
The implementation is still a work in progress and relies on devel-
opment versions of dependencies!
Sander van der Burg nix-processmgmt
References
Blog posts:
A Nix-based functional organization for managing processes,
https://sandervanderburg.blogspot.com/2019/11/
a-nix-based-functional-organization-for.html
A declarative process manager-agnostic deployment
framework based on Nix tooling,
https://sandervanderburg.blogspot.com/2020/02/
a-declarative-process-manager-agnostic.html
Deploying container and application services with Disnix,
https://sandervanderburg.blogspot.com/2020/04/
deploying-container-and-application.html
Sander van der Burg nix-processmgmt
References
Blog posts:
Using Disnix as a simple and minimalistic dependency-based
process manager,
https://sandervanderburg.blogspot.com/2020/06/
using-disnix-as-simple-and-minimalistic.html
Experimenting with Nix and the service management
properties of Docker,
https://sandervanderburg.blogspot.com/2020/08/
experimenting-with-nix-and-service.html
Assigning unique IDs to services in Disnix deployment models,
https://sandervanderburg.blogspot.com/2020/09/
assigning-unique-ids-to-services-in.html
Sander van der Burg nix-processmgmt
References
E. Dolstra, The Purely Functional Software Deployment
Model, PhD thesis, Chapter 9,
https://edolstra.github.io/pubs/phd-thesis.pdf
Sander van der Burg nix-processmgmt
Questions
Sander van der Burg nix-processmgmt

Contenu connexe

Tendances

開放運算&GPU技術研究班
開放運算&GPU技術研究班開放運算&GPU技術研究班
開放運算&GPU技術研究班Paul Chao
 
Using NixOS for declarative deployment and testing
Using NixOS for declarative deployment and testingUsing NixOS for declarative deployment and testing
Using NixOS for declarative deployment and testingSander van der Burg
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOpsОмские ИТ-субботники
 
Advanced Task Scheduling with Amazon ECS (June 2017)
Advanced Task Scheduling with Amazon ECS (June 2017)Advanced Task Scheduling with Amazon ECS (June 2017)
Advanced Task Scheduling with Amazon ECS (June 2017)Julien SIMON
 
CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015Brandon Philips
 
Dockerを利用したローカル環境から本番環境までの構築設計
Dockerを利用したローカル環境から本番環境までの構築設計Dockerを利用したローカル環境から本番環境までの構築設計
Dockerを利用したローカル環境から本番環境までの構築設計Koichi Nagaoka
 
Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Sneha Inguva
 
Docker remote-api
Docker remote-apiDocker remote-api
Docker remote-apiEric Ahn
 
What Have Syscalls Done for you Lately?
What Have Syscalls Done for you Lately?What Have Syscalls Done for you Lately?
What Have Syscalls Done for you Lately?Docker, Inc.
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a NutshellCoreOS
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganetikawamuray
 
Declare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyDeclare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyMoby Project
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Praguetomasbart
 
Containers: What are they, Really?
Containers: What are they, Really?Containers: What are they, Really?
Containers: What are they, Really?Sneha Inguva
 
高レイテンシwebサーバのGKE構築と beta機能アレコレのハナシ
高レイテンシwebサーバのGKE構築と beta機能アレコレのハナシ高レイテンシwebサーバのGKE構築と beta機能アレコレのハナシ
高レイテンシwebサーバのGKE構築と beta機能アレコレのハナシJunpei Nomura
 
Deploying MongoDB sharded clusters easily with Terraform and Ansible
Deploying MongoDB sharded clusters easily with Terraform and AnsibleDeploying MongoDB sharded clusters easily with Terraform and Ansible
Deploying MongoDB sharded clusters easily with Terraform and AnsibleAll Things Open
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionSysdig
 
Nomad, l'orchestration made in Hashicorp - Bastien Cadiot
Nomad, l'orchestration made in Hashicorp - Bastien CadiotNomad, l'orchestration made in Hashicorp - Bastien Cadiot
Nomad, l'orchestration made in Hashicorp - Bastien CadiotParis Container Day
 

Tendances (20)

開放運算&GPU技術研究班
開放運算&GPU技術研究班開放運算&GPU技術研究班
開放運算&GPU技術研究班
 
Using NixOS for declarative deployment and testing
Using NixOS for declarative deployment and testingUsing NixOS for declarative deployment and testing
Using NixOS for declarative deployment and testing
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Advanced Task Scheduling with Amazon ECS (June 2017)
Advanced Task Scheduling with Amazon ECS (June 2017)Advanced Task Scheduling with Amazon ECS (June 2017)
Advanced Task Scheduling with Amazon ECS (June 2017)
 
CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015
 
Dockerを利用したローカル環境から本番環境までの構築設計
Dockerを利用したローカル環境から本番環境までの構築設計Dockerを利用したローカル環境から本番環境までの構築設計
Dockerを利用したローカル環境から本番環境までの構築設計
 
Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)
 
Docker remote-api
Docker remote-apiDocker remote-api
Docker remote-api
 
Ansible docker
Ansible dockerAnsible docker
Ansible docker
 
What Have Syscalls Done for you Lately?
What Have Syscalls Done for you Lately?What Have Syscalls Done for you Lately?
What Have Syscalls Done for you Lately?
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
 
Declare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyDeclare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and Moby
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Containers: What are they, Really?
Containers: What are they, Really?Containers: What are they, Really?
Containers: What are they, Really?
 
高レイテンシwebサーバのGKE構築と beta機能アレコレのハナシ
高レイテンシwebサーバのGKE構築と beta機能アレコレのハナシ高レイテンシwebサーバのGKE構築と beta機能アレコレのハナシ
高レイテンシwebサーバのGKE構築と beta機能アレコレのハナシ
 
Deploying MongoDB sharded clusters easily with Terraform and Ansible
Deploying MongoDB sharded clusters easily with Terraform and AnsibleDeploying MongoDB sharded clusters easily with Terraform and Ansible
Deploying MongoDB sharded clusters easily with Terraform and Ansible
 
Paris container day june17
Paris container day   june17Paris container day   june17
Paris container day june17
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
 
Nomad, l'orchestration made in Hashicorp - Bastien Cadiot
Nomad, l'orchestration made in Hashicorp - Bastien CadiotNomad, l'orchestration made in Hashicorp - Bastien Cadiot
Nomad, l'orchestration made in Hashicorp - Bastien Cadiot
 

Similaire à nix-processmgmt: An experimental Nix-based process manager-agnostic framework

Deploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package managerDeploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package managerSander van der Burg
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with PuppetKris Buytaert
 
The NixOS project and deploying systems declaratively
The NixOS project and deploying systems declarativelyThe NixOS project and deploying systems declaratively
The NixOS project and deploying systems declarativelySander van der Burg
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptDocker, Inc.
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peekmsyukor
 
Postgres the hardway
Postgres the hardwayPostgres the hardway
Postgres the hardwayDave Pitts
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetesLiran Cohen
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with PuppetKris Buytaert
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOpsandersjanmyr
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Ben Hall
 
Dysnomia: complementing Nix deployments with state deployment
Dysnomia: complementing Nix deployments with state deploymentDysnomia: complementing Nix deployments with state deployment
Dysnomia: complementing Nix deployments with state deploymentSander van der Burg
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Ben Hall
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作Philip Zheng
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Ben Hall
 
Deploying .NET services with Disnix
Deploying .NET services with DisnixDeploying .NET services with Disnix
Deploying .NET services with DisnixSander van der Burg
 

Similaire à nix-processmgmt: An experimental Nix-based process manager-agnostic framework (20)

The Nix project
The Nix projectThe Nix project
The Nix project
 
The Nix project
The Nix projectThe Nix project
The Nix project
 
Deploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package managerDeploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package manager
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
 
The NixOS project and deploying systems declaratively
The NixOS project and deploying systems declarativelyThe NixOS project and deploying systems declaratively
The NixOS project and deploying systems declaratively
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build Script
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
 
Postgres the hardway
Postgres the hardwayPostgres the hardway
Postgres the hardway
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOps
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Dysnomia: complementing Nix deployments with state deployment
Dysnomia: complementing Nix deployments with state deploymentDysnomia: complementing Nix deployments with state deployment
Dysnomia: complementing Nix deployments with state deployment
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
Deploying .NET services with Disnix
Deploying .NET services with DisnixDeploying .NET services with Disnix
Deploying .NET services with Disnix
 

Plus de Sander van der Burg

Deploying (micro)services with Disnix
Deploying (micro)services with DisnixDeploying (micro)services with Disnix
Deploying (micro)services with DisnixSander van der Burg
 
Hydra: Continuous Integration and Testing for Demanding People: The Details
Hydra: Continuous Integration and Testing for Demanding People: The DetailsHydra: Continuous Integration and Testing for Demanding People: The Details
Hydra: Continuous Integration and Testing for Demanding People: The DetailsSander van der Burg
 
Hydra: Continuous Integration and Testing for Demanding People: The Basics
Hydra: Continuous Integration and Testing for Demanding People: The BasicsHydra: Continuous Integration and Testing for Demanding People: The Basics
Hydra: Continuous Integration and Testing for Demanding People: The BasicsSander van der Burg
 
A Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentSander van der Burg
 
A Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentSander van der Burg
 
Techniques and lessons for improvement of deployment processes
Techniques and lessons for improvement of deployment processesTechniques and lessons for improvement of deployment processes
Techniques and lessons for improvement of deployment processesSander van der Burg
 
A Generic Approach for Deploying and Upgrading Mutable Software Components
A Generic Approach for Deploying and Upgrading Mutable Software ComponentsA Generic Approach for Deploying and Upgrading Mutable Software Components
A Generic Approach for Deploying and Upgrading Mutable Software ComponentsSander van der Burg
 
A Self-Adaptive Deployment Framework for Service-Oriented Systems
A Self-Adaptive Deployment Framework for Service-Oriented SystemsA Self-Adaptive Deployment Framework for Service-Oriented Systems
A Self-Adaptive Deployment Framework for Service-Oriented SystemsSander van der Burg
 
Disnix: A toolset for distributed deployment
Disnix: A toolset for distributed deploymentDisnix: A toolset for distributed deployment
Disnix: A toolset for distributed deploymentSander van der Burg
 
Automated Deployment of Hetergeneous Service-Oriented System
Automated Deployment of Hetergeneous Service-Oriented SystemAutomated Deployment of Hetergeneous Service-Oriented System
Automated Deployment of Hetergeneous Service-Oriented SystemSander van der Burg
 
Pull Deployment of Services: Introduction, Progress and Challenges
Pull Deployment of Services: Introduction, Progress and ChallengesPull Deployment of Services: Introduction, Progress and Challenges
Pull Deployment of Services: Introduction, Progress and ChallengesSander van der Burg
 
Software Deployment in a Dynamic Cloud
Software Deployment in a Dynamic CloudSoftware Deployment in a Dynamic Cloud
Software Deployment in a Dynamic CloudSander van der Burg
 
Atomic Upgrading of Distributed Systems
Atomic Upgrading of Distributed SystemsAtomic Upgrading of Distributed Systems
Atomic Upgrading of Distributed SystemsSander van der Burg
 
Model-driven Distributed Software Deployment
Model-driven Distributed Software DeploymentModel-driven Distributed Software Deployment
Model-driven Distributed Software DeploymentSander van der Burg
 
Model-driven Distributed Software Deployment
Model-driven Distributed Software DeploymentModel-driven Distributed Software Deployment
Model-driven Distributed Software DeploymentSander van der Burg
 
Model-driven Distributed Software Deployment laymen's talk
Model-driven Distributed Software Deployment laymen's talkModel-driven Distributed Software Deployment laymen's talk
Model-driven Distributed Software Deployment laymen's talkSander van der Burg
 

Plus de Sander van der Burg (18)

The Monitoring Playground
The Monitoring PlaygroundThe Monitoring Playground
The Monitoring Playground
 
Deploying (micro)services with Disnix
Deploying (micro)services with DisnixDeploying (micro)services with Disnix
Deploying (micro)services with Disnix
 
Hydra: Continuous Integration and Testing for Demanding People: The Details
Hydra: Continuous Integration and Testing for Demanding People: The DetailsHydra: Continuous Integration and Testing for Demanding People: The Details
Hydra: Continuous Integration and Testing for Demanding People: The Details
 
Hydra: Continuous Integration and Testing for Demanding People: The Basics
Hydra: Continuous Integration and Testing for Demanding People: The BasicsHydra: Continuous Integration and Testing for Demanding People: The Basics
Hydra: Continuous Integration and Testing for Demanding People: The Basics
 
A Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software Deployment
 
A Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software Deployment
 
Techniques and lessons for improvement of deployment processes
Techniques and lessons for improvement of deployment processesTechniques and lessons for improvement of deployment processes
Techniques and lessons for improvement of deployment processes
 
A Generic Approach for Deploying and Upgrading Mutable Software Components
A Generic Approach for Deploying and Upgrading Mutable Software ComponentsA Generic Approach for Deploying and Upgrading Mutable Software Components
A Generic Approach for Deploying and Upgrading Mutable Software Components
 
A Self-Adaptive Deployment Framework for Service-Oriented Systems
A Self-Adaptive Deployment Framework for Service-Oriented SystemsA Self-Adaptive Deployment Framework for Service-Oriented Systems
A Self-Adaptive Deployment Framework for Service-Oriented Systems
 
Pull Deployment of Services
Pull Deployment of ServicesPull Deployment of Services
Pull Deployment of Services
 
Disnix: A toolset for distributed deployment
Disnix: A toolset for distributed deploymentDisnix: A toolset for distributed deployment
Disnix: A toolset for distributed deployment
 
Automated Deployment of Hetergeneous Service-Oriented System
Automated Deployment of Hetergeneous Service-Oriented SystemAutomated Deployment of Hetergeneous Service-Oriented System
Automated Deployment of Hetergeneous Service-Oriented System
 
Pull Deployment of Services: Introduction, Progress and Challenges
Pull Deployment of Services: Introduction, Progress and ChallengesPull Deployment of Services: Introduction, Progress and Challenges
Pull Deployment of Services: Introduction, Progress and Challenges
 
Software Deployment in a Dynamic Cloud
Software Deployment in a Dynamic CloudSoftware Deployment in a Dynamic Cloud
Software Deployment in a Dynamic Cloud
 
Atomic Upgrading of Distributed Systems
Atomic Upgrading of Distributed SystemsAtomic Upgrading of Distributed Systems
Atomic Upgrading of Distributed Systems
 
Model-driven Distributed Software Deployment
Model-driven Distributed Software DeploymentModel-driven Distributed Software Deployment
Model-driven Distributed Software Deployment
 
Model-driven Distributed Software Deployment
Model-driven Distributed Software DeploymentModel-driven Distributed Software Deployment
Model-driven Distributed Software Deployment
 
Model-driven Distributed Software Deployment laymen's talk
Model-driven Distributed Software Deployment laymen's talkModel-driven Distributed Software Deployment laymen's talk
Model-driven Distributed Software Deployment laymen's talk
 

Dernier

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 

Dernier (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 

nix-processmgmt: An experimental Nix-based process manager-agnostic framework

  • 1. nix-processmgmt: An experimental Nix-based process manager-agnostic framework Sander van der Burg October 17, 2020 Sander van der Burg nix-processmgmt
  • 2. Nix package manager: a powerful solution Conveniently construct packages from source code and all its required build-time dependencies Build determinism. Same hash code → (nearly) bit-identical build Transparent binary deployments (by using substitutes) Store multiple versions and variants safely next to each other Thanks to the hash prefixes and the Nix store Unprivileged user deployments Multiple operating systems: Linux, macOS, FreeBSD, others Sander van der Burg nix-processmgmt
  • 3. Nix: development environments We can conveniently install and use all kinds of packages without interfering with the host system’s packages. nix-shell example $ python --version Python 2.7.15 $ node --version node: command not found $ nix-shell -p python3 nodejs $ python --version Python 3.8.5 $ which python /nix/store/z65l1jqvxa58zzwwa3bvglb6asj4y8cv-python3-3.8.5/bin/python $ node --version v12.18.4 $ which node /nix/store/2w6ilfh7zmbz9zqvphgxinmbn3wdqa1b-nodejs-12.18.4/bin/node Sander van der Burg nix-processmgmt
  • 4. Nix package manager: deploying services? Sander van der Burg nix-processmgmt
  • 5. Nix package manager: not a service manager Nix does not manage application services/processes’ life-cycles. Sander van der Burg nix-processmgmt
  • 6. Nix: service deployment integrations There are sister projects that complement Nix with process manage- ment: NixOS. Generates systemd unit files to manage services. Requires you to switch to a fully Nix-managed Linux distribution. nix-darwin. Generates launchd daemon configuration files. Only works on macOS. Sander van der Burg nix-processmgmt
  • 7. Nix: service deployment integrations Nix can also be used to augment other process management solu- tions: Docker. Docker uses a package manager in Dockerfiles for the construction of images. Nix can be used as a replacement for conventional package managers. Nix can be used to fully build Docker images. Not always not a compelling use case for Nix beginners → they typically download prebuilt images from Docker Hub. Docker is built around Linux technologies (e.g. namespaces) and deploys Linux software Sander van der Burg nix-processmgmt
  • 8. nix-processmgmt: A general solution complementing Nix with process management Sander van der Burg nix-processmgmt
  • 9. nix-processmgmt: A general solution complementing Nix with process management Driven by Nix and the Nix expression language Based on simple conventions: function definitions and an attribute set with function invocations Similar to how packages are organized in Nixpkgs Works with process dependencies as well: the framework arranges the ordering, if needed Process-manager agnostic: Integrates with sysvinit scripts, supervisord, systemd, launchd, bsdrc scripts, cygrunsrv Even with systems that are not qualified as process managers: disnix, docker Sander van der Burg nix-processmgmt
  • 10. nix-processmgmt: A general solution complementing Nix with process management Operating system agnostic: Works on NixOS, but it is not a requirement Conventional Linux distros, macOS, FreeBSD, Cygwin Unprivileged user installations A switch to disable creation of users, and changing user permissions No advanced concepts required, such as namespaces and cgroups The solution relies on conflict avoidance, rather than isolation Sander van der Burg nix-processmgmt
  • 11. Example: a simple web application system Sander van der Burg nix-processmgmt
  • 12. Packaging the webapp process (sysvinit, verbose) {createSystemVInitScript, webapp, port ? 5000}: createSystemVInitScript { name = "webapp"; description = "Example web application"; environment.PORT = port; activities = { start = ’’ log_info_msg "Starting Example web application..." loadproc ${webapp}/bin/webapp -D evaluate_retval ’’; stop = ’’ log_info_msg "Stopping Example web application..." killproc ${webapp}/bin/webapp evaluate_retval ’’; restart = "$0 stop; sleep 1; $0 start"; status = "statusproc ${webapp}/bin/webapp"; }; runlevels = [ 3 4 5 ]; } Sander van der Burg nix-processmgmt
  • 13. Packaging the webapp process (sysvinit, declarative) {createSystemVInitScript, webapp, port ? 5000}: createSystemVInitScript { name = "webapp"; process = "${webapp}/bin/webapp"; args = [ "-D" ]; runlevels = [ 3 4 5 ]; environment.PORT = port; } We can also specify the daemon that we want to manage, instead of the activity implementations. Most sysvinit activities (start, stop, restart, reload, status) can be inferred. Sander van der Burg nix-processmgmt
  • 14. Packaging the webapp process (systemd) The following function composes a systemd unit instead of a sysvinit script: {createSystemdService, webapp, port ? 5000}: createSystemdService { name = "webapp"; Unit = { Description = "Example web application"; }; Service = { ExecStart = "${webapp}/bin/webapp"; Environment.PORT = port; Type = "simple"; }; } The framework contains many other process manager- specific abstraction functions: createSupervisordProgram, createLaunchdDaemon, createBSDRCScript etc. Sander van der Burg nix-processmgmt
  • 15. Packaging the webapp process (agnostic) Process manager-agnostic abstraction of the webapp service: {createManagedProcess, webapp, port ? 5000}: createManagedProcess { name = "webapp"; description = "Example web application"; process = "${webapp}/bin/webapp"; daemonArgs = [ "-D" ]; # For process managers that prefer daemons environment.PORT = port; overrides = { sysvinit.runlevels = [ 3 4 5 ]; }; } Invokes the required target-specific abstraction function, e.g. createSystemVInitScript, createSystemdService overrides override/augment process manager-specific parameters You can treat foreground processes and daemons separately, for optimal user experience Sander van der Burg nix-processmgmt
  • 16. Instantiatable webapp processes {createManagedProcess, webapp}: {instanceSuffix ? "", instanceName ? "webapp${instanceSuffix}", port ? 5000}: createManagedProcess { name = instanceName; inherit instanceName; # To ensure a unique PID file name description = "Example web application"; process = "${webapp}/bin/webapp"; daemonArgs = [ "-D" ]; # For process managers that prefer daemons environment.PORT = port; overrides = { sysvinit.runlevels = [ 3 4 5 ]; }; } instanceName: ensures that the daemon command generates unique PID file Outer-function header: parameters that apply to all instances. Inner-function header: instance parameters. A unique combination ensures that multiple instances can co-exist. Sander van der Burg nix-processmgmt
  • 17. Composing process instances { pkgs ? import <nixpkgs> {} , stateDir ? "/var" , forceDisableUserChange ? false, processManager}: let constructors = import ./constructors.nix { inherit pkgs stateDir forceDisableUserChange processManager; }; in rec { webapp1 = rec { # First webapp instance port = 5000; dnsName = "webapp1.local"; pkg = constructors.webapp { inherit port; instanceSuffix = "1"; }; }; webapp2 = rec { # Second webapp instance port = 5001; dnsName = "webapp2.local"; pkg = constructors.webapp { inherit port; instanceSuffix = "2"; }; }; ... } Sander van der Burg nix-processmgmt
  • 18. Composing process instances { pkgs ? import <nixpkgs> {} , stateDir ? "/var" , forceDisableUserChange ? false, processManager}: let constructors = import ./constructors.nix { inherit pkgs stateDir forceDisableUserChange processManager; }; in rec { ... # Nginx with a config that redirects users to the appropriate webapp # instance based on the virtual host header nginx = { pkg = constructors.nginxReverseProxyHostBased { # Process dependencies used to set up redirections in nginx.conf webapps = [ webapp1 webapp2 ]; port = 8080; } {}; }; } Sander van der Burg nix-processmgmt
  • 19. Demo: deploying the system and using it Deploy the process instances as sysvinit scripts: $ nixproc-sysvinit-switch processes.nix Open the first webapp instance (via the Nginx reverse proxy): $ curl -H ’Host: webapp1.local’ http://localhost:8080 Open the second webapp instance (via the Nginx reverse proxy): $ curl -H ’Host: webapp2.local’ http://localhost:8080 Sander van der Burg nix-processmgmt
  • 20. Demo: all kinds of process manager integrations Deploy as systemd units (in a user session): $ nixproc-systemd-switch --user processes.nix Deploy as supervisord programs (stateless): $ nixproc-supervisord-deploy-stateless processes.nix Deploy on FreeBSD as BSD rc scripts: $ nixproc-bsdrc-switch processes.nix Deploy as Docker containers per service (with shared Nix store and host networking): $ nixproc-docker-switch processes.nix Sander van der Burg nix-processmgmt
  • 21. Demo: screenshots Sander van der Burg nix-processmgmt
  • 22. Other features of nix-processmgmt Automatic creation of users and groups (createCredentials function) nixproc-id-assign: Automated assignment of unique IDs for TCP/UDP ports, UIDs, GIDs to process instances Using Disnix as a process orchestrator (works on all platforms where Nix/Disnix is supported) Sander van der Burg nix-processmgmt
  • 23. Combining nix-processmgmt with Disnix We can use any process manager, do distributed deployment and combine processes with non-process based services (e.g. Java web applications in an Apache Tomcat container): Sander van der Burg nix-processmgmt
  • 24. Example services packaged for nix-processmgmt HTTP/application servers: Apache HTTP server Nginx Apache Tomcat Database: PostgreSQL MariaDB/MySQL MongoDB InfluxDB Misc: Docker Supervisord svnserve Sander van der Burg nix-processmgmt
  • 25. Future work Deploy containers with multiple processes (WIP) Mutable service containers (WIP) s6 / s6-rc backend Work on a test strategy for services Maybe write an RFC? Sander van der Burg nix-processmgmt
  • 26. Availability https://github.com/svanderburg/nix-processmgmt The implementation is still a work in progress and relies on devel- opment versions of dependencies! Sander van der Burg nix-processmgmt
  • 27. References Blog posts: A Nix-based functional organization for managing processes, https://sandervanderburg.blogspot.com/2019/11/ a-nix-based-functional-organization-for.html A declarative process manager-agnostic deployment framework based on Nix tooling, https://sandervanderburg.blogspot.com/2020/02/ a-declarative-process-manager-agnostic.html Deploying container and application services with Disnix, https://sandervanderburg.blogspot.com/2020/04/ deploying-container-and-application.html Sander van der Burg nix-processmgmt
  • 28. References Blog posts: Using Disnix as a simple and minimalistic dependency-based process manager, https://sandervanderburg.blogspot.com/2020/06/ using-disnix-as-simple-and-minimalistic.html Experimenting with Nix and the service management properties of Docker, https://sandervanderburg.blogspot.com/2020/08/ experimenting-with-nix-and-service.html Assigning unique IDs to services in Disnix deployment models, https://sandervanderburg.blogspot.com/2020/09/ assigning-unique-ids-to-services-in.html Sander van der Burg nix-processmgmt
  • 29. References E. Dolstra, The Purely Functional Software Deployment Model, PhD thesis, Chapter 9, https://edolstra.github.io/pubs/phd-thesis.pdf Sander van der Burg nix-processmgmt
  • 30. Questions Sander van der Burg nix-processmgmt