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 orchestrator command to CLI #1801

Merged
merged 7 commits into from
May 5, 2020
Merged

Add orchestrator command to CLI #1801

merged 7 commits into from
May 5, 2020

Conversation

NicolasMahe
Copy link
Member

@NicolasMahe NicolasMahe commented May 2, 2020

Dependant on #1798

Add orchestrator command to CLI

It's currently a bit complicated to test and will be simplified by the future docker dev image.

Terminal 1: start the validator

  1. Init genesis with one validator and put the files in ~/.mesg-node (you can use the dev-chain files from Create pre-configured dev docker image #1806)
  2. start it
./bin/mesg-daemon start

Terminal 2: start the orchestrator

go run ./cmd/mesg-cli orchestrator start --authorized-pubkeys="mesgpub1addwnpepqvdrcdvg3x4tf0y5aapn47njxapdu4l0jgsjzcm2klp9a7eztva66eqnadt" --mnemonic="neutral false together tattoo matrix stamp poem mouse chair chair grain pledge mandate layer shiver embark struggle vicious antenna total faith genre valley mandate" --chain-id="mesg-dev-chain"

Terminal 3: compile the service, create it and start it with right env:

Service used https://github.com/liteflow-services/webhook

  1. Compile it with special command liteflow-dev service:compile ./webhook
  2. Publish it
go run ./cmd/mesg-cli tx service create --from cli --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto '{"sid":"webhook","name":"Webhook","description":"Receive HTTP connections and emit events with the data","repository":"https://github.com/mesg-foundation/service-webhook","configuration":{"ports":["3005"]},"dependencies":[],"tasks":[{"key":"call","description":"This task will call a webhook and return the result of the call","inputs":[{"key":"url","description":"URL that you want to call","type":"String","object":[]},{"key":"data","description":"Data the you want to send","type":"Object","optional":true,"object":[]},{"key":"headers","description":"Additional headers that you want to send","type":"Object","optional":true,"object":[]}],"outputs":[{"key":"status","description":"Status code returned by the request","type":"Number","object":[]},{"key":"data","description":"Date returned by the request","type":"Any","object":[]}]}],"events":[{"key":"request","description":"This even is emitted every time the server receive a `POST` request on the URL `/webhook`.","data":[{"key":"data","description":"All the data contained in the request data","type":"Object","object":[]},{"key":"headers","description":"All the headers contained in the request","type":"Object","object":[]}]}],"source":"QmZ1Pg2kdX1b3tFNy8sh2omTfaqmcTmBA2J8kmNP4HeYpM"}'
  1. Generate env
npm run cmd -- start FDvQhZTwYPay1CnurZ1GQowSVEhKQr6Q1p89p87T2PHS --mnemonic "spike raccoon obscure program raw large unaware dragon hamster round artist case fall wage sample velvet robust legend identify innocent film coral picture organ" --engineAddress "mesg1t9h20sn3lk2jdnak5eea4lkqxkpwyfaadtqk4t"```

Put the result (following) in .env file:

export LITEFLOW_ENDPOINT="localhost:50052"
export LITEFLOW_SERVICE_HASH="FDvQhZTwYPay1CnurZ1GQowSVEhKQr6Q1p89p87T2PHS"
export LITEFLOW_ENV_HASH="6fVwCj7Qy1G4EStpLSGTi8yQgUF3egc4YPQESso5A2w7"
export LITEFLOW_REGISTER_SIGNATURE="M5RZNUGeZgjrImlkWOxt6TSxMFrm2dJWVcyclUr5CJoYBl8gEM+mCrSEO1sYINyM1ix10IBCJjwqF/qCA4fWxA=="
  1. Start the service
source .env
node index.js

Terminal 4: compile process and trigger it

  1. compile process using compiler cmd (npm run cmd -- process /Users/nico/Development/liteflow-labs/app/simple.yml)
  2. publish it
go run ./cmd/mesg-cli tx process create --from cli --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto '{"name":"webhook","nodes":[{"key":"node-0","Type":{"type":"mesg.types.Process_Node_Event_","value":{"event":{"instanceHash":"HVso8L6QtToBNomhDvnfobygr6YAtmXRAqdkJsw9s36e","eventKey":"request"}}}},{"key":"node-1-inputs","Type":{"type":"mesg.types.Process_Node_Map_","value":{"map":[{"Key":"data","Value":{"Value":{"type":"mesg.types.Process_Node_Map_Output_Map_","value":{"map":[{"Key":"foo","Value":{"Value":{"type":"mesg.types.Process_Node_Map_Output_StringConst","value":{"string_const":"bar"}}}}]}}}},{"Key":"url","Value":{"Value":{"type":"mesg.types.Process_Node_Map_Output_StringConst","value":{"string_const":"https://webhook.site/ad536a28-4b19-4562-a756-f20027e25c5a"}}}}]}}},{"key":"node-1","Type":{"type":"mesg.types.Process_Node_Task_","value":{"task":{"instanceHash":"HVso8L6QtToBNomhDvnfobygr6YAtmXRAqdkJsw9s36e","taskKey":"call"}}}}],"edges":[{"src":"node-0","dst":"node-1-inputs"},{"src":"node-1-inputs","dst":"node-1"}]}'
  1. trigger it
curl -X POST localhost:3005/webhook --data '{"foo":"bar2"}'

@NicolasMahe NicolasMahe changed the title Feature/orchestrator cli Add orchestrator command to CLI May 3, 2020
@NicolasMahe NicolasMahe self-assigned this May 3, 2020
@NicolasMahe NicolasMahe requested a review from antho1404 May 3, 2020 09:58
@NicolasMahe NicolasMahe added this to the next milestone May 3, 2020
@NicolasMahe NicolasMahe added the release:add Pull requests that add something label May 3, 2020
@NicolasMahe NicolasMahe marked this pull request as ready for review May 3, 2020 09:58
cmd/mesg-cli/orchestrator.go Outdated Show resolved Hide resolved
@NicolasMahe NicolasMahe merged commit b4c8c43 into dev May 5, 2020
@NicolasMahe NicolasMahe deleted the feature/orchestrator-cli branch May 5, 2020 12:21
This was referenced May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:add Pull requests that add something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants