Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #183 from craftcms/feature/ssl-support
Browse files Browse the repository at this point in the history
Add nitrod daemon and Nitro API
  • Loading branch information
jasonmccallister authored Aug 1, 2020
2 parents 16b4d1d + b16530e commit 5d465c1
Show file tree
Hide file tree
Showing 50 changed files with 2,311 additions and 86 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ composer.lock
/production-site
nitro.exe
*.sql
/nitrod
20 changes: 20 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
before:
hooks:
- go mod download
- go test ./...
builds:
- binary: nitro
id: nitro
Expand All @@ -13,7 +14,17 @@ builds:
- darwin
goarch:
- amd64
- arm64
ldflags: -s -w -X github.com/craftcms/nitro/internal/cmd.Version={{.Version}}
- binary: nitrod
id: nitrod
main: ./cmd/nitrod/main.go
goos:
- linux
goarch:
- amd64
- arm64
ldflags: -s -w -X github.com/craftcms/nitro/internal/nitrod.Version={{.Version}}
archives:
-
name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"
Expand All @@ -26,6 +37,15 @@ archives:
format_overrides:
- goos: windows
format: zip
-
name_template: "nitrod_{{.Os}}_{{.Arch}}"
id: nitrod
builds:
- nitrod
replacements:
amd64: x86_64
files:
- nitrod.service
snapshot:
name_template: "{{ .Tag }}"
changelog:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

### Unreleased

## Added
- Added the `nginx` command to with `restart`, `stop`, and `start` commands.
- Added the `nitrod` daemon that runs in the virtual machine and exposes a gRPC API on port `50051`. New Nitro features will be implemented using the API.
- Added the `php` command to with `restart`, `stop`, and `start` commands. ([#57](https://github.com/craftcms/nitro/issues/57))
- Added the `iniset` command under `php` to quickly modify init settings for `max_execution_time`, `max_input_vars`, `max_input_time`, `upload_max_filesize`, `max_file_uploads`, and `memory_limit`. ([#138](https://github.com/craftcms/nitro/issues/138))

## Fixed
- Fixed an issue where composer was slow when ran from inside the virtual machine. ([#186](https://github.com/craftcms/nitro/issues/186))
- Fixed an issue where switching the PHP version was not setting the version as the default. ([#192](https://github.com/craftcms/nitro/issues/192))

### 1.0.0-beta.10 - 2020-06-04

## Added
Expand Down
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build:
build-win:
GOOS="windows" go build -ldflags="-s -w -X 'github.com/craftcms/nitro/internal/cmd.Version=${VERSION}'" -o nitro.exe ./cmd/cli
local: build
mv nitro /usr/local/bin/nitro
sudo mv nitro /usr/local/bin/nitro
local-win: build-win
mv nitro.exe "${HOME}"/Nitro/nitro.exe
test:
Expand All @@ -15,3 +15,22 @@ releaser:
goreleaser --skip-publish --rm-dist --skip-validate
win-home:
mkdir "${HOME}"/Nitro
api-build:
GOOS=linux go build -ldflags="-s -w" -o nitrod ./cmd/nitrod
api: api-build
multipass transfer nitrod nitro-dev:/home/ubuntu/nitrod
multipass exec nitro-dev -- sudo systemctl stop nitrod
multipass exec nitro-dev -- sudo cp /home/ubuntu/nitrod /usr/sbin/
multipass exec nitro-dev -- sudo chmod u+x /usr/sbin/nitrod
multipass transfer nitrod.service nitro-dev:/home/ubuntu/nitrod.service
multipass exec nitro-dev -- sudo cp /home/ubuntu/nitrod.service /etc/systemd/system/
multipass exec nitro-dev -- sudo systemctl daemon-reload
multipass exec nitro-dev -- sudo systemctl start nitrod
setup: api-build
multipass transfer nitrod nitro-dev:/home/ubuntu/nitrod
multipass transfer nitrod.service nitro-dev:/home/ubuntu/nitrod.service
multipass exec nitro-dev -- sudo cp /home/ubuntu/nitrod.service /etc/systemd/system/
multipass exec nitro-dev -- sudo systemctl daemon-reload
multipass exec nitro-dev -- sudo systemctl start nitrod
proto:
protoc internal/nitrod/nitrod.proto --go_out=plugins=grpc:.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ To add a new mount, follow these steps:
2. Run `nitro apply` to apply the `nitro.yaml` change to the machine.
Once that’s done, yous should be able to tunnel into your machine using the [`ssh`](#ssh) command, and see the
Once that’s done, you should be able to tunnel into your machine using the [`ssh`](#ssh) command, and see the
newly-mounted directory in there.
## Running Multiple Machines
Expand All @@ -274,7 +274,7 @@ $ nitro init -m <machine>
```
Replace `<machine>` with the name you want to give your new machine. Machine names can only include letters,
numbers, underscores, and hyphen.
numbers, underscores, and hyphens.
This command will run through the same prompts you saw when creating your primary machine after you first installed
Nitro. Once it’s done, you’ll have a new Multipass machine, as well as a new configuration file for it at
Expand Down
38 changes: 38 additions & 0 deletions cmd/nitrod/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"flag"
"fmt"
"log"
"net"

"google.golang.org/grpc"

"github.com/craftcms/nitro/internal/nitrod"
)

func main() {
// assign the port as a flag with a default
port := flag.String("port", "50051", "which port nitro API should listen on")
flag.Parse()

// create the network listener
lis, err := net.Listen("tcp", "0.0.0.0:"+*port)
if err != nil {
log.Fatal(err)
}

// create the grpc server
s := grpc.NewServer()

// register our services
nitrod.RegisterNitroServiceServer(s, nitrod.NewNitroService())
nitrod.RegisterSystemServiceServer(s, nitrod.NewSystemService())

fmt.Println("running nitrod on port", *port)

// server the grpc service
if err := s.Serve(lis); err != nil {
log.Fatal("error when running the server", err)
}
}
58 changes: 0 additions & 58 deletions cmd/test/main.go

This file was deleted.

9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.14

require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/golang/protobuf v1.4.2
github.com/jasonmccallister/hosts v0.0.0-20200601172247-0748f05d919e
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.3.0 // indirect
Expand All @@ -17,8 +18,12 @@ require (
github.com/spf13/viper v1.6.3
github.com/stretchr/testify v1.5.1 // indirect
github.com/txn2/txeh v1.3.0
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f
golang.org/x/text v0.3.2 // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6 // indirect
golang.org/x/text v0.3.3 // indirect
google.golang.org/genproto v0.0.0-20200722002428-88e341933a54 // indirect
google.golang.org/grpc v1.30.0
google.golang.org/protobuf v1.25.0
gopkg.in/ini.v1 v1.55.0 // indirect
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.0-20200506231410-2ff61e1afc86
Expand Down
Loading

0 comments on commit 5d465c1

Please # to comment.