This blog post is recording my journey on proof of concept development on ionic 4 capacitor & PWA development in December 2018, just note down some obstacles I faced or founding in the journey, and this is not a tutorial. Although Progressive Web Apps (PWA) are installable without app store, as of today business requirement may still need the distribute channel via app store. With ionic (UI) and Cordova framework, one single code base can serve native apps and web apps together. ionic 4 Capacitor or Stencil Capacitor is still in Release Candidate in Dec 2018, and 1.0 production in 2019. Integrate with Angular. Cross platform: iOS, android, Web, Electron (win & macOS) Stencil: web component (similar to ploymer), reusable, independent (angular, react, vue) selected Capacitor as per requirement. Toolings: Intellij Idea (as subscribed), or Visual Studio Code (free) Installation follow the official documentation. run $ ng build to create /www folder Creation on iOS & android projects is smooth and easy. ionic team really did a great job there. However, PWA isn’t that user-friendly. npm install @ionic/pwa-elements only adding UI component. PWA services worker angular-worker: basic usage, npm install -g @angular/cli ; ng add @angular/pwa ngsw-config.json. workbox: advance usage. pre-caching, background sync …etc very difficult to setup, due to angular builder. Need to manually add “glob”: “workbox-<Component>.<dev|prod>.js” to angular.json . See https://golb.hplar.ch/2018/06/workbox-serviceworker-in-angular-project.html for more details Development $ ionic server –> live reload on source folder, so PWA doesn’t work as pre-caching & routing info in /www (build) folder, not src/service-worker.js edit package.json, add "dist": "ng build && workbox injectManifest" Then run $ npm run dist to build. Then run $ npx cap serve alternatively, http-server can be used, that will use /www file. e.g. http-server www -c-1 -o -a -S localhost -p 8200 HTTPS: PWA works on localhost, 192.168.x.x . Others need HTTPS. It won’t work on non-SSL, took some time to find out, as office wifi is not Class C network. Yet it runs okay at home.
唔想每個server 行一次 ssh 再run command,寫個script 同做一次所有servers 既時間差。不過下次再run 就可以慳好多時間。IaC / automation always win. Ansible playbook 可能都有,可惜冇機會用到Ansible 。 放左去gist。有用既請拍下 likecoin ,Thanks:)
公司最近有個deployment,要run個SQL patch。係QA 同staging 都冇事,點知一去production run左30mins 都未行完,terminated & rollback. 原來係其中一個update statement 行subquery,where id = (select …) mysql 會run select on each row 🙁 DataSet 一大,慢到嘔。
1 2 3 4 5 6 7 8 9 10 11 |
CREATE TABLE alarm_backup SELECT * FROM alarm; UPDATE alarm a SET a.status = 'active' , ....... WHERE a.id = ( SELECT al.id FROM alarm_backup ab JOIN device d ON ab.device_id = d.id JOIN ...... WHERE ..... ); |
其實subquery 係唔需要⋯⋯
1 2 3 4 5 6 7 |
CREATE TABLE alarm_backup SELECT * FROM alarm; UPDATE alarm a JOIN device d ON a.device_id = d.id JOIN ...... SET a.status = 'active' , ....... WHERE ..... ; |
故事教訓我地: 1) 放假返黎之後小心點,你唔係到個時既Peer review 都要睇返。 2) 唔好咁容易信你上司,上左神枱技術係會回塘 😂