botpress-food-order-module
Steps to deploy new version
1 - node webpack.js --compile (the most important step) Note: this command works on nodejs v5.12.0 (Use nvm list -> nvm use v5.12.0 -> node -v) 2 - clean project (by commit changes to repository) git add . git commit -m "commit message" git push 3 - npm version (got the current module version) 4 - npm version newVersionNumber (versioning the module version) 5 - npm publish (to publish a new package version to npm.js server)
Note:
-
To publish a new version to npmjs; it requires login with npm.js's account npm whoami (To display the current npm user account) npm login (To authenticate to npmjs server, then can use npm publish command)
-
After publishing a new version to npmjs server; go to root project which needs it then run command npm install botpress-food-order-module@latest
-
To remove the module; run the following command npm uninstall botpress-food-order-module npm cache clean --force (It will remove the package module from node_modules directory)
Local Test
go to root directory of any project that uses this package, then run command below: npm install ../module-directory (ex: ../botpress-food-order-module) npm link ../module-directory
https://www.sqlite.org/cli.html
sqlit3 Usage- sqlite3 food-order-bot/data/db.sqlite (Connect to sqlite db)
- .help (Display help)
- .tables (Show all tables)
- .header on (Show header)
- .mode column (Show column)
- select * from orders limit 1;
- .schema tableName or PRAGMA table_info(tableName); (Show table's schema info)
- .exit (Quite SQLite3)
http://pm2.keymetrics.io/docs/usage/quick-start/
pm2 Usagepm2 list pm2 delete all pm2 log
Git Usage
-
git clone git-url (To clone proj)
-
git branch (List all branches in the current directory)
-
git checkout -- filename (To discard changes of filename)
-
git checkout branchname (To checkout or switch branch name)
-
git reset --hard (Reset all changes to HEAD version)
-
git clean -f -d (To get rid of untracked files and directories in your working copy)
-
git status
-
git diff filename
-
git tag -a v1.4 -m 'version 1.4' (To create tag)
-
git log (Display all commit logs)
-
git revert --no-commit log-id (Note In order to revert to any previous committed version, we need to perform revert as stack - i.e revert the lastest and then revert to before the latest and so on)
-
git add .
-
git commit -m "revert msg"
-
git push
Batch command on Ubuntu to start all bot projects
bot food-order-bot food-order-excel-report food-order-webview start (bash command below) #!/bin/bash pm2 delete all cd food-order-bot pm2 start npm -- start cd ../food-order-webview pm2 start app.js --name="webview" --watch cd ../food-order-excel-report pm2 start index.js --name="excel-report" --watch Note: to run start script pwd is bot, then use ./start pwd is food-order-bot, then use ../start
PORT=1339 pm2 start npm --name "clientside-demo" -- start pm2 start npm --name "exjs-classified" --watch -- start
Step checkout proj
~# ssh-keygen -t rsa -b 4096 (/root/.ssh/id_rsa) ~# eval "$(ssh-agent -s)" Agent pid 419 ~# ssh-add -k ./.ssh/id_rsa ~# cat ./.ssh/id_rsa.pub ~# git clone git@fellow.plan.io:fellow/coloplast-g2g-goes-couch.g2g-salesforce-clientside.git
then go to plan.io -> my account -> public keys -> add -> paste copied id_rsa.pub -> save
Server deployment
https://shizoo.social7-wifi.com/modules/botpress-food-order-module ssh root@shizoo.social7-wifi.com
https://fooddemo.social7-wifi.com/modules/botpress-food-order-module ssh root@fooddemo.social7-wifi.com
Note before renew letsencrypt certificate, servername must be set) sudo certbot renew
npmjs.com davysorn/fellow$24 shizooforyou@gmail.com / fellow$24
Commands
httpd -V (Show apache version) (Both) httpd -t (Check config syntax) (Both) httpd -S (List all virtual hosts) (Both) apachectl configtest (Ubuntu Only) apachectl -V (Ubuntu Only)
sudo lsof -PiTCP -sTCP:LISTEN sudo lsof -i -P | grep -i "80" curl -I -L finekh.local
Ubuntu Commands
/etc/apache2/apache2.conf /etc/apache2/sites-available sudo a2ensite sitedomainname sudo systemctl reload apache2 service apache2 start sudo apachectl -t apachectl configtest
/etc/nginx/nginx.conf /etc/nginx/conf.d/ /etc/nginx/sites-available service nginx start nginx -t
systemctl status|stop|start|restart|reload|disable|enable nginx service --status-all (Display all running services) service status
ufw app list sudo ufw status lsb_release -a df -h df -h --total ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's//.*$//'
Mac Commands
/usr/local/etc/httpd/httpd.conf /usr/local/etc/httpd/vhost/
/usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/conf.d/
brew services list brew services start|stop|restart httpd brew services start|stop|restart nginx brew services start|stop|restart mysql brew services start|stop|restart php brew list brew info httpd
hostname (Show computer name)
Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down AH00015: Unable to open logs Note sudo apachectl start (to bind to port)
nginx configuration example
server { listen 8080; listen 443 ssl; server_name localhost; #server_name shizoo.social7-wifi.com;
ssl_certificate /etc/letsencrypt/live/shizoo.social7-wifi.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/shizoo.social7-wifi.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
#ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
ssl_dhparam /etc/ssl/certs/dhparam.pem;
location / {
#root /var/www/food-order-staging;
root /var/www/gitlab/food-order-bot;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /webview/ {
#root /var/www/food_order_webview_bot/;
root /var/www/gitlab/food-order-webview;
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}