FYI: I managed to get it to work - I still get the message about trying to save 
the changes file and it not being possible - however my error was not 
specifying —no-default-preferences  and also  around correctly escaping the 
command line - the “eval” command is a bit tricky as you need to escape any “ 
characters as they are badly interpreted.

Thus I had to do the following:

const child = exec('./pharo Pharo.image --no-default-preferences eval "Lambda 
processJSON: \'' + JSON.stringify(event).replace(/"/g,'\\"') + '\'"', (error) 
=> {
   
}

It looks like a simple lambda execution takes about 2700 to 2900ms

Tim

> On 28 Jun 2017, at 01:01, Tim Mackinnon <[email protected]> wrote:
> 
> Hi Sven, I'm curious how you are running your image.
> 
> I am following this tutorial - 
> https://aws.amazon.com/blogs/compute/scripting-languages-for-aws-lambda-running-php-ruby-and-go/
>  
> <https://aws.amazon.com/blogs/compute/scripting-languages-for-aws-lambda-running-php-ruby-and-go/>
> 
> And am running pharo like the GO example by exec'ing via node js.
> 
> My aim was to write an Alexa service in pharo vs nodejs like I have been 
> doing.
> 
> I was assuming I can call pharo via the eval option and stringify the Jaon 
> Alexa Paramus and return a result via Stdout... well in theory, and the work 
> to make pharo play better in wider ecosystem.
> 
> It should work, and it seems you did make it work... but how?
> 
> Like you, I am wondering when I run it on an ec2 instance (non lambda), why 
> it takes so long to load? It feels like it can be faster?
> 
> Tim
> 
> Sent from my iPhone
> 
> 
> 
> Sent from my iPhone
> On 27 Jun 2017, at 20:21, Sven Van Caekenberghe <[email protected] 
> <mailto:[email protected]>> wrote:
> 
>> 
>>> On 27 Jun 2017, at 18:05, Tim Mackinnon <[email protected] 
>>> <mailto:[email protected]>> wrote:
>>> 
>>> Hi - I am trying to run a pharo image in lambda (as an experiment) - 
>>> however I get an error from Pharo about not being able to write to the 
>>> changes file?
>>> 
>>> As I am just evaluating some code - I’m not really coding, so don’t need a 
>>> changes file - is there a command line option to not require it?
>> 
>> That is really strange, it should just work (it does for me using the zero 
>> config scripts).
>> 
>> I would try to use absolute (resolved) paths as much as possible.
>> 
>>> Also, am I running pharo the most efficient way - I’m using eval on the 
>>> command line and referencing a class with a class method - but is this the 
>>> best way?
>> 
>> Yes, that is ok.
>> 
>>> Thanks,
>>> 
>>> Tim
>>> 
>>> "errorMessage": "Command failed: ./pharo Pharo.image eval \"Lambda 
>>> processJSON: 
>>> '{\"key3\":\"value3\",\"key2\":\"value2\",\"key1\":\"value1\"}'\"\n'Pharo 
>>> cannot write to the changes file named /var/task/Pharo.changes.\n\nPlease 
>>> check that you have write permission for this file.\n\nYou won''t be able 
>>> to save this image correctly until you fix this.'\n\u001b[31mError: Can't 
>>> find the requested 
>>> origin\n\u001b[0mUnixResolver(PlatformResolver)>>cantFindOriginError\n[ 
>>> self cantFindOriginError ] in 
>>> UnixResolver(PlatformResolver)>>directoryFromEnvVariableNamed: in Block: [ 
>>> self cantFindOriginError 
>>> ]\nUnixResolver(PlatformResolver)>>directoryFromEnvVariableNamed:or:\nUnixResolver(PlatformResolver)>>directoryFromEnvVariableNamed:\nUnixResolver>>home\n[
>>>  self home / '.config' ] in UnixResolver>>preferences in Block: [ self home 
>>> / '.config' 
>>> ]\nUnixResolver(PlatformResolver)>>directoryFromEnvVariableNamed:or:\nUnixResolver>>preferences\nUnixResolver(FileSystemResolver)>>resolve:\nSystemResolver(FileSystemResolver)>>unknownOrigin:\nSystemResolver(FileSystemResolver)>>resolve:\nInteractiveResolver>>unknownOrigin:\n[
>>>  self unknownOrigin: origin ] in InteractiveResolver>>resolve: in Block: [ 
>>> self unknownOrigin: origin 
>>> ]\nIdentityDictionary(Dictionary)>>at:ifAbsent:\nInteractiveResolver>>resolve:\nFileLocator>>resolve\nFileLocator(AbstractFileReference)>>exists\nGlobalIdentifierStonPersistence(GlobalIdentifierPersistence)>>shouldCallPreviousPersistence\nGlobalIdentifierStonPersistence(GlobalIdentifierPersistence)>>ensure:\nGlobalIdentifier>>ensure\nGlobalIdentifier
>>>  class>>initializeUniqueInstance\nGlobalIdentifier 
>>> class>>uniqueInstance\nSystemSettingsPersistence 
>>> class>>resumeSystemSettings\n[ :persistence | persistence 
>>> resumeSystemSettings ] in PharoCommandLineHandler>>runPreferences in Block: 
>>> [ :persistence | persistence resumeSystemSettings 
>>> ...etc...\nBlockClosure>>cull:\nSystemDictionary(Dictionary)>>at:ifPresent:\nSmalltalkImage>>at:ifPresent:\nPharoCommandLineHandler>>runPreferences\nPharoCommandLineHandler>>activate\nPharoCommandLineHandler
>>>  class(CommandLineHandler class)>>activateWith:\n\u001b[0m",
>>>  "errorType": "Error",
>>>  "stackTrace": [
>>>    "'Pharo cannot write to the changes file named /var/task/Pharo.changes.",
>>>    "",
>>>    "Please check that you have write permission for this file.",
>>>    "",
>>>    "You won''t be able to save this image correctly until you fix this.'",
>>>    "\u001b[31mError: Can't find the requested origin",
>>>    "\u001b[0mUnixResolver(PlatformResolver)>>cantFindOriginError",
>>>    "[ self cantFindOriginError ] in 
>>> UnixResolver(PlatformResolver)>>directoryFromEnvVariableNamed: in Block: [ 
>>> self cantFindOriginError ]",
>>>    "UnixResolver(PlatformResolver)>>directoryFromEnvVariableNamed:or:",
>>>    "UnixResolver(PlatformResolver)>>directoryFromEnvVariableNamed:",
>>>    "UnixResolver>>home",
>>>    "[ self home / '.config' ] in UnixResolver>>preferences in Block: [ self 
>>> home / '.config' ]",
>>>    "UnixResolver(PlatformResolver)>>directoryFromEnvVariableNamed:or:",
>>>    "UnixResolver>>preferences",
>>>    "UnixResolver(FileSystemResolver)>>resolve:",
>>>    "SystemResolver(FileSystemResolver)>>unknownOrigin:",
>>>    "SystemResolver(FileSystemResolver)>>resolve:",
>>>    "InteractiveResolver>>unknownOrigin:",
>>>    "[ self unknownOrigin: origin ] in InteractiveResolver>>resolve: in 
>>> Block: [ self unknownOrigin: origin ]",
>>>    "IdentityDictionary(Dictionary)>>at:ifAbsent:",
>>>    "InteractiveResolver>>resolve:",
>>>    "FileLocator>>resolve",
>>>    "FileLocator(AbstractFileReference)>>exists",
>>>    
>>> "GlobalIdentifierStonPersistence(GlobalIdentifierPersistence)>>shouldCallPreviousPersistence",
>>>    "GlobalIdentifierStonPersistence(GlobalIdentifierPersistence)>>ensure:",
>>>    "GlobalIdentifier>>ensure",
>>>    "GlobalIdentifier class>>initializeUniqueInstance",
>>>    "GlobalIdentifier class>>uniqueInstance",
>>>    "SystemSettingsPersistence class>>resumeSystemSettings",
>>>    "[ :persistence | persistence resumeSystemSettings ] in 
>>> PharoCommandLineHandler>>runPreferences in Block: [ :persistence | 
>>> persistence resumeSystemSettings ...etc...",
>>>    "BlockClosure>>cull:",
>>>    "SystemDictionary(Dictionary)>>at:ifPresent:",
>>>    "SmalltalkImage>>at:ifPresent:",
>>>    "PharoCommandLineHandler>>runPreferences",
>>>    "PharoCommandLineHandler>>activate",
>>>    "PharoCommandLineHandler class(CommandLineHandler class)>>activateWith:",
>>>    "\u001b[0m",
>>>    "ChildProcess.exithandler (child_process.js:204:12)",
>>>    "emitTwo (events.js:106:13)",
>>>    "ChildProcess.emit (events.js:191:7)",
>>>    "maybeClose (internal/child_process.js:886:16)",
>>>    "Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)"
>>>  ]
>>> }
>>> 
>>> 
>> 
>> 

Reply via email to