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

added groups example #2

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:webapp}"
},
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 8000
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
}
]
}
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
# Fuge Examples
This repository contains example systems, demonstrating the use of Fuge. To run the examples, clone this repository. Each example comes with it's own README.md and setup instructions. Each example builds on the next so it is advisable to run them in order.

The examples are as follows:
# External service

## hello-world
The simplest possible configuration. Runs a single service in the fuge shell.
This example is the same as the External service example but it has extra some extra services. This shows how services can be grouped, so that commands can be applied to the whole group. Adderservice minusservice multiplyservice and divideservice all have a common group, [group: sums] created in the fuge.yml file.

## simple-system
A simple system system configuration with a front end and a single microservice.
These groups can be seen using the ps command. You can apply all the usual commands to groups, eg, you can start the sums group hee with:

## kubernetes-emulation
A slightly more complex microservice system that emulates a production Kuberntes environment. This example has a front end and two services one of which reads and writes to a mongo database which is provided through the use of a docker mongo container.

## using-docker-compose
The same system as in the previous example but one service and the mongo container are configured using a docker compose file that is included in the fuge configuration. Demonstrates how to use compose file in conjunction with fuge.
```sh
$ fuge shell fuge/fuge.yml
fuge> start sums
fuge>ps
```

## services-and-infrastructure
This example demonstrates how to keep infrastrcutre, i.e. databases, queuing systems etc.. running in the background with docker-compose but still have them discoverable to microservices managed with fuge. This is a useful pattern when killing and restarting the fuge shell.
name type group status watch tail
mongo container default not managed
adderservice process sums running yes yes
minusservice process sums running yes yes
multiplyservice process sums running yes yes
divideservice process sums running yes yes
auditservice process default stopped yes yes
importantauditservice process critical stopped yes yes

## external-service
This example demonstrates how to connect shared infrastructure in development. For example, in some development teams a shared database is used for development. This example builds on the `services-and-infrastructure` example and introduces an additional shared database system through an external DNS record set that allows services to discover this databse as they would in production using DNS.


All commands that work with 'all', will also work with groups.

Start, restart, stop, pull, status, tail, grep, etc.



If you don't create a group for a service in the fuge.yml file then it will be given an automatic group of default, by default.
104 changes: 104 additions & 0 deletions change-variables-while-running/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

# Fuge Changing Environment Variables

# To change a value in memory:


Start the shell by running "fuge shell fuge/fuge.yml"


Run setval <process> to see all the available variables and their values, for example:

fuge> setval adderservice

variables in adderservice
type = process
path = c:\MAMP\htdocs\fuge\fuge-examples\change-variables-while-running\adderservice
run = node service.js
ports = adderservice,8087,
name = adderservice
specific =
status = enabled
environment = ADDERSERVICE_SERVICE_HOST,127.0.0.1,ADDERSERVICE_SERVICE_PORT,8087,ADDERSERVICE_PORT,tcp://127.0.0.1:8087,ADDERSERVICE_PORT_8087_TCP,tcp://127.0.0.1:8087,ADDERSERVICE_PORT_8087_TCP_PROTO,tcp,ADDERSERVICE_PORT_8087_TCP_PORT,8087,ADDERSERVICE_PORT_8087_TCP_ADDR,127.0.0.1,WEBAPP_SERVICE_HOST,127.0.0.1,WEBAPP_SERVICE_PORT,3006,WEBAPP_PORT,tcp://127.0.0.1:3006,WEBAPP_PORT_3006_TCP,tcp://127.0.0.1:3006,WEBAPP_PORT_3006_TCP_PROTO,tcp,WEBAPP_PORT_3006_TCP_PORT,3006,WEBAPP_PORT_3006_TCP_ADDR,127.0.0.1,SERVICE_HOST,127.0.0.1,SERVICE_PORT,8087
host = 127.0.0.1
tail = true
monitor = true
monitor_excludes = 0,**/node_modules/**,1,**/.git/**,2,*.log
delay_start = 0
restart_on_error = false


Run setval <process> <variable> to see a single variable, for example:

fuge> setval adderservice delay_start
delay_start = 0

We can run setval <process> <variable> <value> to set a new value for the variable:

fuge> setval adderservice delay_start 3000
Old value = 0
New value = 3000

Run setval with the env argument to set a new environment value for an enviornment variable <process> env <variable> <value> , for excample:

fuge> setval adderservice env SERVICE_PORT 8088
Old value = 8087
New value = 8088


###############################################


# To change a value from the fuge.yml file while Fuge is running:


Start the shell by running "fuge shell fuge/fuge.yml"

change a value in the yml file:

adderservice:
type: process
path: ../adderservice
run: 'node service.js'
terminate: SIGINT
ports:
- adderservice=8087

Here we could change SIGINT to SIGTERM, change the port number, change the path, or add new properties and values .
Note: Changing the path will disable the service if an invalid path is entered, but the system will keep running. Another way to disable a service is to use setval (above) to set the status to disabled.


So, after changing the fuge.yml file and saving the changes, run 'rel' to reload the changed values, and type 'y' to confirm, or 'n' to cancel:

fuge> rel
There are changed values in: adderservice
Do you want to apply these changes? (y/n)
y


##################################################

























Loading