# OpenFlow
Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scalable NodeRed implementation.
Also the "backend" for [OpenRPA](https://github.com/open-rpa/OpenRPA)

Join slack for giving feedback [#openrpa](https://slack.openrpa.dk/)

Build to run on docker, how to setup docker is not supported on GitHub/slack

#### Quick start running openflow using npm

For now only Linux (tested on ubuntu 18LTS) and windows is supported
Install NodeJS version 12 (google how to do that, if in doubt, hint, use nvm if you got the wrong version installed)
Also you need to have an installation of  [mongoDB](https://www.mongodb.com/download-center/community) and [RabbitMQ](https://www.rabbitmq.com/download.html)

On window, run from a command prompt with admin rights

On windows this will require build tools to be present, install using

`npm install --global windows-build-tools`

On linux this will require build tools to be present. On ubuntu you can install using

`sudo apt-get install gcc g++ make`

Then to install and run OpenFlow, install the openiap package 

`npm i openiap -g`

On Linux run with sudo

`sudo npm i openiap -g`

then create a template configuration file using 
`openflow-cli --init`

open and edit openflow.env, if needed, then install the service using

on windows

`openflow-cli --install openflow`

and on Linux remember to use sudo

`sudo openflow-cli --install openflow`

then open a browser and visit [localhost.openrpa.dk](http://localhost.openrpa.dk) 

#### Quick start running openflow nodered using npm

For now only Linux (tested on ubuntu 18LTS) and windows is supported
Install NodeJS version 12 (google how to do that, if in doubt, hint, use nvm if you got the wrong version installed)
This require you to have openflow installed somewhere, or you can use our public openflow at [app.openiap.io](https://app.openiap.io) (noderedremote.env)

On window, run from a command prompt with admin rights

On windows this will require build tools to be present, install using

`npm install --global windows-build-tools`

On linux this will require build tools to be present. On ubuntu you can install using

`sudo apt-get install gcc g++ make`

Then to install and run OpenFlow Nodered, install the openflow-nodered package 
`npm i openflow-nodered -g`

On Linux run with sudo

`sudo npm i openflow-nodered -g`

then create a template configuration file using 
`openflow-nodered-cli --init`

this will create 2 environment files with an example of how to connect to a locally installed openflow or how to connect to [app.openiap.io](https://app.openiap.io)
So lets assume you want to run a remote openflow connected to [app.openiap.io](https://app.openiap.io) 

on windows

`openflow-nodered-cli --install noderedremote`

and on Linux remember to use sudo

`sudo openflow-nodered-cli --install noderedremote`

this will prompt for a pre-created username and password, and then install a local service with the name noderedremote and start it

then open a browser and visit [localhost.openrpa.dk:1880](http://localhost.openrpa.dk:1880) 

#### Quick start using docker

To quickly get started with your own installation you can use one of these docker-compose files.
download the file you want
rename to docker-compose.yaml 
open a shell and cd to that folder you downloaded the file to, and type
docker-compose up
or
docker-compose up -d

[docker-compose-traefik.yml](https://github.com/open-rpa/openflow/blob/master/docker-compose-traefik.yml) is for people running docker ce/docker desktop or docker swarm

[docker-compose-toolbox.yml](https://github.com/open-rpa/openflow/blob/master/docker-compose-toolbox.yml) is for people running [docker toolbox](https://docs.docker.com/toolbox/toolbox_install_windows/) 

[docker-compose.yml](https://github.com/open-rpa/openflow/blob/master/docker-compose.yml) is for developers who don't want to install [mongoDB](https://www.mongodb.com/download-center/community)/[RabbitMQ](https://www.rabbitmq.com/download.html) or an easy way to run one instance while debugging the other.

Then you can access the API/web on [http://localhost.openrpa.dk](http://localhost.openrpa.dk) ( or [http://toolbox.openrpa.dk](http://toolbox.openrpa.dk) )
You can access nodered on [http://nodered1.localhost.openrpa.dk](http://nodered1.localhost.openrpa.dk) ( or [http://nodered1.toolbox.openrpa.dk](http://nodered1.toolbox.openrpa.dk) )
and RabbitMQ on  [http://mq.localhost.openrpa.dk](http://mq.localhost.openrpa.dk) ( or [http://mq.toolbox.openrpa.dk](http://mq.toolbox.openrpa.dk) )

The first username and password you try to login as, will be created and made admin

For help with running on [kubernetes](https://kubernetes.io/) or self hosting contact [OpenIAP](https://openrpa.dk/) for a support agreement

#### Developer setup



Install [VSCode](https://code.visualstudio.com/download), [NodeJS 12](https://nodejs.org/en/download/),  [mongoDB](https://www.mongodb.com/download-center/community) and [RabbitMQ](https://www.rabbitmq.com/download.html) 
You need to [enable management console](https://www.rabbitmq.com/management.html) in RabbitMQ 

Clone this repo into a folder, in a shell type

`git clone https://github.com/open-rpa/openflow.git`

go to the folder with openflow

`cd openflow`

Install gulp and typescript globally

`npm i gulp typescript browserify tsify -g`

install packages for openflow api/web

`npm i`

install packages for NodeRED by 

`cd OpenFlowNodeRED`
`npm i`

`cd ..`

Now open in VS code

`code OpenFlow.code-workspace`

at the top level create a folder called config and inside create a file called .env ( notice it starting with a dot)

and add this content to the file

```bash
nodered_id=nodered1
nodered_sa=nodered1
port=80
nodered_port=1880
nodered_domain_schema=$nodered_id$.localhost.openrpa.dk
tls_crt=
tls_key=
tls_ca=

 
 
NODE_ENV=development

saml_federation_metadata=http://localhost.openrpa.dk/issue/FederationMetadata/2007-06/FederationMetadata.xml
saml_issuer=uri:localhost.openrpa.dk
# saml_entrypoint=http://localhost.openrpa.dk/issue
# saml_baseurl=http://localhost.openrpa.dk:1880/

allow_personal_nodered=false
allow_user_registration=true
# mongodb_url=mongodb://localhost:27017
# mongodb_db=openflow

# api_bypass_perm_check=true
update_acl_based_on_groups=true
multi_tenant=false

websocket_max_package_count=1048576

api_ws_url=ws://localhost.openrpa.dk
domain=localhost.openrpa.dk
protocol=http
amqp_url=amqp://localhost
aes_secret=7TXsxf7cn9EkUqm5h4MEWGjzkxkNCk2K
auto_create_users=true
auto_create_domains=
skip_history_collections=audit,jslog
```
Lastly you need to allow powershell scripts to run, i don't know what is the recommended setting, i normally just go with bypass

`Set-ExecutionPolicy Bypass -Force`

Now you can run this by going to run ( Ctrl+Shit+D) and selecting OpenFlow in the dropdown box and press play button, select OpenFlowNodeRed in the dropdown and press play again

Lastly we need to start a background job that copies asserts to the dist folder, go to Terminal tab and add a new shelll, then type

`gulp`

You can now access openflow web on [http://localhost.openrpa.dk](http://localhost.openrpa.dk) and nodered on [http://localhost.openrpa.dk:1880](http://localhost.openrpa.dk:1880)

For further help or education contact [OpenIAP](https://openrpa.dk/) for a support agreement