-
Notifications
You must be signed in to change notification settings - Fork 135
Install_Linux_Lightsail
Y-Bot runs on a 4GB 2 CPU Unbuntu 16.04 server using AWS Lightsail instance. These instructions are for installing onto this instance. Given the many different ways of running Linux daemons, this is not the only way, just the only way I use !
First provision an AWS Server instance. Y-Bot is quite a memory intensive app and therefore I recommend the 4GB, 2 CPU instance at approx $40/month. I also include a static IP address so that I can make Y-Bot demonstration publicly available.
Once provisioned, use the SSH client to log in to your new server
First we need to set up the system. Make sure all out repos are up to date
sudo apt-get update
If you don't intend to host anything else then you can skip the section on apache install, otherwise
sudo apt-get install apache2
sudo apache2ctl configtest
sudo nano /etc/apache2/apache2.conf
sudo apache2ctl configtest
sudo systemctl restart apache2
sudo systemctl daemon-reload
Next for Y-Bot we need Python 3.6 or greater. For Ubuntu 16.04, this requires the following commands
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
sudo ln -s /usr/bin/python3.6 /usr/bin/python3
python3
Next we need Git installing to make sure we can pull down from github
sudo apt-get install git
Once Git is installed we can download the latest and greatest code from Github
cd /opt
mkdir program-y
cd program-y
git init .
git remote add program-y https://github.com/keiffster/program-y
git pull program-y master
Next, we need Pip and the Python 3 version of it. Once this is installed we can install all of the necessary Python dependencies.
sudo apt-get install python3-pip
pip3 install --upgrade pip
pip3 install -r requirements.txt
We can now install and configured all of the clients starting with the REST service.
The first service to get up and running is the REST service, this loads the core Y-Bot Grammar and will also be
called by all other clients in our multi-client configuration.
We can first test it works locally by using the shell script servusai-rest.sh
$ cd bots/servusai/rest
$ ./servusai-rest.sh
Initiating REST Service...
Loading, please wait...
No bot root argument set, defaulting to [/opt/program-y/bots/y-bot]
REST Client running on 0.0.0.0:8989
REST Client running in http mode, careful now !
Here we can see that it's running in HTTP mode, on port 8989. This is fine as we are not exposing the REST service at this time to the outside world. Instead, it will be called by all other services so HTTP is fine.
We can now create Linux daemon to keep running the REST Client when we log out
sudo cp servusai-rest.service /etc/systemd/system/servusai-rest.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-rest.service
sudo systemctl start servusai-rest.service
systemctl status servusai-rest.service
If we make any further mods we can restart the server and pick up the new config and code changes with the following
sudo systemctl restart servusai-re.service
If anything goes wrong, you can check the systemd logs with the following command
journalctl -u servusai.service
Now we havea REST service running against a full Y-Bot grammar, lets tests it's working. Servusai ships with a fully configured Console client that connects to the REST Client.
$ cd ../console
$ ./console.sh
Loading, please wait...
No bot root argument set, defaulting to [.]
None, App: v1.0.0 Grammar v1.0.0, initiated March 14, 2017
Hi, how can I help you today?
>>> hello
Hiya!
>>> what are you
I'm a full-time virtual assistant.
>>>
This shows that its connected, working and the REST client is responding correctly. Lets configure all of the other clients
First we check its working locally using the script web.sh
$ cd ../web
$ ./web.sh
Loading, please wait...
No bot root argument set, defaulting to [.]
Initiating Webchat Client...
WebChat Client running on 0.0.0.0:8080
Webchat Client running in http mode, careful now !
Again, the above output shows that the webchat client is running and waiting for us to connect on https://servus.com
NOTE: I have the Lighsail instance running nginx which handles the SSL config and redirects all HTTP traffic to HTTPS
If all working, lets also make this a service
sudo cp servusai-web.service /etc/systemd/system/servusai-web.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-web.service
sudo systemctl start servusai-web.service
systemctl status servusai-web.service
Next client is the Telegram client, so head over that folder and lets check its all working by running the local script.
$ cd ../telegram
$ ./telegram.sh
Loading Telegram client, please wait. See log output for progress...
No bot root argument set, defaulting to [.]
Telegram client running....
If that works, then we are ready to unstall the client as another daemon
sudo cp servusai-telegram.service /etc/systemd/system/servusai-telegram.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-telegram.service
sudo systemctl start servusai-telegram.service
systemctl status servusai-telegram.service
As this point we should see that the server started and is running. Head over to your favourite Telegram client and you can start chatting with Servus AI at @servusai
Another good client ot have running is the XMPP client. In this instance, it is configured to run as Google Talk Client. $ cd ../xmpp $ ./xmpp.sh Loading XMPP client, please wait. See log output for progress... No bot root argument set, defaulting to [.] XMPP client running [programy@gmail.com]
Once we have proved it is all working, we can install it as a service like all the other ones we have done already.
```bash
sudo cp servusai-xmpp.service /etc/systemd/system/servusai-xmpp.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-xmpp.service
sudo systemctl start servusai-xmpp.service
systemctl status servusai-xmpp.service
Again, the last command tells us if the service is up and running.
So the pattern starts to become familiar now
$ cd ../twitter
$ ./twitter.sh
Loading Twitter client, please wait. See log output for progress...
No bot root argument set, defaulting to [.]
Twitter client running as [programybot]...
Now we have confirmed it will run on the server we can install it as a service
sudo cp servusai-twitter.service /etc/systemd/system/servusai-twitter.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-twitter.service
sudo systemctl start servusai-twitter.service
systemctl status servusai-twitter.service
Again lets head over to the socket client and test it locally first
$ cd ../socket
$ ./socket.sh
Loading, please wait...
No bot root argument set, defaulting to [.]
TCP Socket server now listening on 127.0.0.1:9999
So that confirms its running, now we can install it as a service
sudo cp servusai-socket.service /etc/systemd/system/servusai-socket.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-socket.service
sudo systemctl start servusai-socket.service
systemctl status servusai-socket.service
And hey presto, we should see that the service is running.
Note that if you keep getting the same tweets responded to, then its likely the storage directory defined in config.yaml is either defined incorrectly or missing.
Facebook is probably one of the more complicated clients to get up and running due to the need to define an SSL url that is a fully defined DNS url
I run nginx as my webserver in front of all the web based clients including the Facebook webhook URL. You will need to configure you server appropriately to expose the port for Facebook client and also ensure its running HTTPS, otherwise Facebook won't like it. So once you have done that lets run the local client first
$ cd ../facebook
$ ./facebook.sh
No bot root argument set, defaulting to [.]
Facebook Client loaded
Facebook Client running on 127.0.0.1:5000
Facebook Client running in http mode, careful now !
Again we can see that its running, so we can go ahead and install it as a service
sudo cp servusai-facebook.service /etc/systemd/system/servusai-facebook.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-facebook.service
sudo systemctl start servusai-facebook.service
systemctl status servusai-facebook.service
So the pattern starts to become familiar now
$ cd ../slack
$ ./slack.sh
Loading Slack client, please wait. See log output for progress...
No bot root argument set, defaulting to [.]
Starter Bot connected and running!
Now we have confirmed it will run on the server we can install it as a service
sudo cp servusai-slack.service /etc/systemd/system/servusai-slack.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-slack.service
sudo systemctl start servusai-slack.service
systemctl status servusai-slack.service
So the pattern starts to become familiar now
$ cd ../twilio
$ ./twilio.sh
No bot root argument set, defaulting to [.]
Twilio Client loaded
Twilio Client running on 127.0.0.1:5000, receiving on +44777777777
Twilio Client running in http mode, careful now !
Now we have confirmed it will run on the server we can install it as a service
sudo cp servusai-twilio.service /etc/systemd/system/servusai-twilio.service
sudo systemctl daemon-reload
sudo systemctl enable servusai-twilio.service
sudo systemctl start servusai-twilio.service
systemctl status servusai-twilio.service
Email: keiffster@gmail.com | Twitter: @keiffster | Facebook: keith.sterling | LinkedIn: keithsterling | My Blog
- Home
- Background
- Guiding Principles
- Reporting an Issue
- Installation
- You And Your Bot
- Bots
- Clients
- Configuration
- AIML
- Sentence Splitting
- Natural Langauge Processing
- Normalization
- Spelling
- Sentiment Analysis
- Translation
- Security
- Hot Reload
- Logging
- Out of Band
- Multi Language
- RDF Support
- Rich Media
- Asynchronous Events
- Triggers
- External Services
- Dynamic Sets, Maps & Vars
- Extensions
- Pre & Post Processors
- Custom Nodes
- The Brain Tree
- Utilities
- Building It Yourself
- Creating Your Own Bot
- Contributing
- Performance Testing
- FAQ
- History
- Website