Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Run alone: a standalone application attempt by Gabriel Sor

296 views

Published on

How can we build an application in Pharo, that we can deliver to the final user, without UI, protecting the source code, and executed in just one click.
In this talk I will present my experience in building a standalone application with Pharo, the drawbacks I found and all the ideas that it inspired.

Published in: Technology
  • Login to see the comments

Run alone: a standalone application attempt by Gabriel Sor

  1. 1. Gabriel Sor
  2. 2. Run Alone: A Pharo standalone application attempt
  3. 3. Deployment Issues ▪ Memory Consumption ▪ Packaging 3
  4. 4. Memory consumption =
  5. 5. Amount of Classes Amount of Packages Tools for load Code Size Full Image 6400 488 Metacello 52MB Fuel Config CommandLineHan dler Monticello Clean Image
  6. 6. How many files are necessary for deploy? 6
  7. 7. Option 1 7 sourcesimage changes VM+
  8. 8. Option 2 8 sourcesimage changes
  9. 9. Option 3 9 + VM
  10. 10. Option 4 10
  11. 11. How To Prepare a Deployment Image on Pharo 11
  12. 12. SmalltalkZen “There are two schools of thought, as far as preparing a Smalltalk image for deployment[...]” Dmitri Zagidulin 12
  13. 13. “ “Take your development image, and strip out unnecessary applications, GUIs, and the development environment itself” Dmitri Zagidulin
  14. 14. Deploy anywhere approach Deploy Anywhere Packaging a customer ready application for Windows, Mac and Linux. Maximiliano Tabacman In Smalltalks 2015, UBA, Argentina.
  15. 15. Deploy anywhere result ▪ A image and a Directory structure ready to deploy
  16. 16. Amount of Classes Amount of Packages Tools for load Code Size Seaside Image 7364 543 Metacello 85.1MB Fuel Config CommandLineHa ndler Monticello Image with Seaside with tests and everything
  17. 17. “ “Start with a minimal clean image, and only load the libraries and classes that you’re actually using to run your application.” Dmitri Zagidulin 17
  18. 18. The minimal image approach Create a deployable image loading the application on the minimal image and disabling the command line handlers.
  19. 19. The minimal image approach Create a deployable image loading the application on the minimal image and disabling the command line handlers.
  20. 20. Stateless Image The application closed to modification 20
  21. 21. What is the Minimal Image? “Kernel image (Shrinked/bootstraped) +Monticello +Network Support (Zinc, Sockets) +Remore repository support +Metacello +CommandLineHandlers (except FuelCommandLineHandler)” Mission Pharo Kernel 1. 1. Mission Pharo Kernel ESUG 2016, Prague Pavel Krivanek and Christophe Demarey 21
  22. 22. Tools necessaries for this approach ▪ Dependency Analyser ▪ Minimal Image ▪ Metacello ▪ ConfigurationOf or BaselineOf is needed ▪ ConfigurationCommandLineHandler ▪ Smalltalk scripts
  23. 23. ““Is slightly more difficult but very rewarding, especially if you’re going to go the Continuous Integration route (via Hudson/Jenkins), because it requires you to know exactly which packages you’re using, what they depend on, the load order, and so on.” Dmitri Zagidulin
  24. 24. Package Analyser Dependencies of 24 Grease -Core Seasid e-Tools Seasid e-Devel opment JQuery- Core Seasid e-Comp onente Seasid e-Core Seasid e-Canv as Javascr ipt-Core Seaside-Examples Potenti al Depend encies Collecti on-Seq uencea ble
  25. 25. Metacello baseline: spec <baseline> spec for: #common do: [ self setUpDependencies: spec. Specpackage: 'Seaside-Examples' with: [ spec requires: #('Grease-Core' 'JQuery-Core' ‘Javascript-Core’ ‘Seaside-Core’ ‘Seaside-Canvas’ ‘Seaside-Componente’ ‘Seaside-Tools’ ‘Seaside-Development’) ]] 25
  26. 26. The minimal image process ▪ Create an entry point object ▪ Create a BaselineOf or ConfigurationOf (Using the Dependency Analyser) ▪ Disable code loading ▪ Remove the changes file ▪ Remove the sources file
  27. 27. Create an entry point object MyApplication MyApplic ationEntr yPoint Starts Click on
  28. 28. Registering Entry Point Object MyApplicationEntryPoint class>>#initialize SessionManager default register: (ClassSessionHandler forClassNamed: self name) inCategory: SessionManager default userCategory 28
  29. 29. StartUp and ShutDown MyApplicationEntryPoint class>>startUp: arg1 MyApplicationManager instance startAlgorithm MyApplicationEntryPoint class>>shutDown: arg1 MyApplicationManager instance stopAlgorithm 29
  30. 30. Get the minimal image
  31. 31. Just the minimal image Amount of Classes Amount of Packages Tools for load Code Size Minimal Image 1429 119 Metacello 8,3MB Monticello Config CommandLineHan dler
  32. 32. In linux doesn’t work curl get.pharo.org/64/ | bash curl get.pharo.org/61-minimal ./pharo Pharo-minimal.image This interpreter (vers. 68021) cannot read image file (vers. 6521). Press CR to quit... 32
  33. 33. Uses the 32 VM Minimal Image doesn’t work with 64 bits VM 33
  34. 34. In linux this works curl get.pharo.org/vm61 | bash curl get.pharo.org/61-minimal | bash ./pharo Pharo-minimal.image eval “its works” 34
  35. 35. Order your ideas Create a development directory Create a exe-factory directory Create the deploy directory Save the minimal image Save the 32 bits VM Proof that all works 35
  36. 36. Development Directory 36 sourcesimage changes VM+
  37. 37. Exe-Factory Directory 37 sources Minimal image changes VM+ Scripts to load code
  38. 38. Deployment Directory 38 + VM
  39. 39. veggie:~$./pharo Pharo-minimal.image config repositoryOfMyApplication BaselineOfMyApplication --install=baseline Just works with SmalltalkHub Load application :linux
  40. 40. C: PharoConsole.exe Pharo-minimal.image config repositoryOfMyApplication BaselineOfMyApplication --install=someVersion Never works Load application: Windows
  41. 41. C: PharoConsole.exe Pharo-minimal.image loadMyApplication.st Load application: Windows
  42. 42. loadMyApplication.st Metacello new baseline: 'MyApplication'; filetreeDirectory:'pathToMyApplication'; load. SmalltalkImage current saveImageInFileNamed:'myApp.image'. SmalltalkImage current snapshot: true andQuit: true 42
  43. 43. Error MCFileTreeRepository uses STON STON is not in the minimal image. 43
  44. 44. So, load STON before Gofer new smalltalkhubUser: 'SvenVanCaekenberghe' project: 'STON'; configurationOf: 'Ston'; loadStable. loadMyApplication code 44
  45. 45. error Undefined Referencies 45
  46. 46. The solution? scriptToLoadSTON cleanAfterNB.st scritpToLoadMyApp pharo-project/pharo-minimal-scripts Thanks Pavel Krivanek!!! 46
  47. 47. Error again Undefined Referencies 47
  48. 48. This works scriptToLoadSTON Smalltalk recompile scritpToLoadMyApp 48
  49. 49. But…. MessageNotUnderstood: receiver of "addTo:" is nil 49
  50. 50. Nor github nor filetree You just can load code from: ▪ Metacello directory ▪ SmalltalkHub repository 50
  51. 51. Possible solution Load MCGitHubRepository and its dependencies: ▪ Metacello-GitHub ▪ Metacello-GitBasedRepository ▪ MonticelloFileTree-Core 51
  52. 52. Good luck!!! 52
  53. 53. veggie:~$./pharo Pharo-minimal.image disableSourceFileAndChanges.st Disable calls to sources and changes files
  54. 54. didisableSourceFileAndChanges.st ChangesLog subclass:'NoChangesLog '. PharoFilesOpener subclass:'NoPharoFilesOpener'. NoChangesLog install. NoPharoFilesOpener install. Smalltalk snapshot:true andQuit:true. Sven Van Caekenberghe :http://forum.world.st
  55. 55. veggie:~$./pharo Pharo-minimal.image disableCommandLineHandlers.st Disable CommandLineHandlers
  56. 56. The minimal image spected result ▪ An immutable image. ▪ Low memory consumption. ▪ Non UI ▪ Just one click execution (in windows)
  57. 57. The minimal image actual result ▪ An immutable image. ▪ Low memory consumption. ▪ Non UI ▪ Just one click execution (in windows)
  58. 58. With Seaside with tests and everything Amount of Classes Amount of Packages Tools for load Code Size Minimal Seaside +STON 2156 175 Metacello 28.4MB Monticello Config CommandLineHan dler
  59. 59. Run Alone: A Pharo standalone application Ex e m Con es In h p ://gi b.co /de t e d a
  60. 60. Future Work Try to Build a deployable image Ready to load the necessary packages using github,gitlab,filetree and then unload all unnecessary objects
  61. 61. 61
  62. 62. https://github.com/despotadesdibujau sormgabriel@gmail.com

×