EA31337/ansible-role-mt-runner

error non zero return code when running metatrader 5/terminal64.exe

Closed this issue · 10 comments

As instructed in EA31337/ansible-role-metatrader#6, I commented out the opensymbols font download. And the metatrader installation completed successfully. But Then the following error occurred.

I checked that main.yml:12 refers to mt_runner_mt_files defined in vars/main.yml But for some reason the variable wasnt fetched(?). I hardcoded the value terminal64.exe in place of the variable reference and the step completed successfully but then the second error occurred which i haven't been able to debug yet.

I'm running ansible-playbook -i "localhost," -c local test.yml -vvv to run the role
test.yml contents:

It will be really helpful if you can provide a running demo with step by step instruction.

---
- hosts: all                                                                                                                                                                                                                                   
  gather_facts: yes                                                                                                                                                                                                                            
  become: yes                                                                                                                                                                                                                                  
  roles:                                                                                                                                                                                                                                       
   - mt-runner 

Error output 1

TASK [mt-runner : Query MT platform path] 
**************************************************************************************************************************
*************************************************************************
task path: /home/ubuntu/.ansible/roles/mt-runner/tasks/main.yml:12                                                                                                                                                                           
fatal: [localhost]: FAILED! => {                                                                                                                                                                                                                 
  "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute '5'. 
  'dict object' has no attribute '5'\n\nThe error appears to be in '/home/ubuntu/.ansible/roles/mt-runner/tasks/main.yml': 
  line 12, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line 
  appears to be:\n\n    - winbind\n- name: Query MT platform path\n  ^ here\n"                                            
}    

Error output 2

fatal: [localhost]: FAILED! => {
  "changed": false,
  "cmd": "wine '/root/.wine/dosdevices/c:/Program Files/MetaTrader 5/terminal64.exe' \"/config:tester.ini\"",
  "delta": "0:00:13.430257",
  "end": "2023-10-15 20:27:29.454976",
  "invocation": {
    "module_args": {
      "_raw_params": "wine '/root/.wine/dosdevices/c:/Program Files/MetaTrader 5/terminal64.exe' \"/config:tester.ini\"",
      "_uses_shell": true,
      "argv": null,
      "chdir": "/root/.wine/dosdevices/c:/Program Files/MetaTrader 5",
      "creates": null,
      "executable": null,
      "removes": null,
      "stdin": null,
      "stdin_add_newline": true,
      "strip_empty_ends": true
    }
  },
  "msg": "non-zero return code",
  "rc": 190,
  "start": "2023-10-15 20:27:16.024719",
  "stderr": "0048:err:ole:start_rpcss Failed to start RpcSs service\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031ad20\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0466 wp=00000000 lp=0031ad20\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031a5e0\n00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 
lp=0031a5e0\n00cc:err:toolbar:Toolbar 
... ... ...
"00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031e2d0",                                                                                                                                                               
"00cc:err:toolbar:ToolbarWindowProc unknown msg 0465 wp=00000000 lp=0031e2d0",                                                                                                                                                               
"00cc:err:ntdll:RtlLeaveCriticalSection section 00000001421B0520 is not acquired"                                                                                                                                                        
],                                                                                                                                                                                                                                           
"stdout": "",                                                                                                                                                                                                                                
"stdout_lines": []                                                                                                                                                                                                                       
}    

Thanks, it's failing on mt-runner/tasks/main.yml:12 which is '{{ mt_runner_mt_files[mt_runner_mt_version].terminal }}' where mt_runner_mt_version is defined in defaults/main.yml as mt_runner_mt_version: '{{ metatrader_version | default(5) }}' (if metatrader_version is not defined, 5 is set by default). So the issue is that mt_runner_mt_files[5] is not defined. I'm going to check what's missing (what should be there, probably the list of expected terminal files) and fix it.

Thanks, it's failing on mt-runner/tasks/main.yml:12 which is '{{ mt_runner_mt_files[mt_runner_mt_version].terminal }}' where mt_runner_mt_version is defined in defaults/main.yml as mt_runner_mt_version: '{{ metatrader_version | default(5) }}' (if metatrader_version is not defined, 5 is set by default). So the issue is that mt_runner_mt_files[5] is not defined. I'm going to check what's missing (what should be there, probably the list of expected terminal files) and fix it.

It was referencing the value "terminal64.exe" so i hardcoded the value and that step worked. I think its failing in a later step where it actually executes the metatrader binary.

I think its failing in a later step where it actually executes the metatrader binary.

For the last step, you've to override some config values, e.g.

vars:
  mt_runner_bt_mt5_config:
    Tester:
      Expert: SomeEa

Or you can use -e to pass it directly from the Ansible's command line. I think TestExpert is the only one required (not empty) so platform won't hang, the rest you can override as you like (check defaults/main.yml the default values).

If the binary fails, you've to check the MetaTrader logs.

For the last step, you've to override some config values, e.g.

vars:
  mt_runner_bt_mt5_config:
    Tester:
      Expert: SomeEa

Or you can use -e to pass it directly from the Ansible's command line. I think TestExpert is the only one required (not empty) so platform won't hang, the rest you can override as you like (check defaults/main.yml the default values).

If the binary fails, you've to check the MetaTrader logs.

I tried setting the Expert variable to the absolute address of my ex5 file. It is still giving the same error.

I tried looking around on the stderr log of metatrader, it says 0048:err:ole:start_rpcss Failed to start RpcSs service and it could be related to skipping the font installation. Here is a relevant post i found on this.

Could you look into this?

0048:err:ole:start_rpcss Failed to start RpcSs service

This is the Wine's error. If the platform was executed, can you check the actual MetaTrader logs from MQL5/ (located in ~/.wine) from the VM itself?

0048:err:ole:start_rpcss Failed to start RpcSs service

This is the Wine's error. If the platform was executed, can you check the actual MetaTrader logs from MQL5/?

Where can i find the logs?

Where can i find the logs?

Can you login to VM (via ssh) where you've installed it and locate installation of MetaTrader directory (somewhere in ~/.wine) and its MQL5/ subdir? There should be couple of .log files which you can find (assuming platform has been run at all). Check the content of these files manually (e.g. cat). However they're in UTF-16 format (not sure if cat can handle it), so use vi/vim or grep.

Currently role doesn't print them by default, it's something to add (GH-9).

Great! so i checked the logs and it says i cannot find the ea i specified, even though the path is specified. Is it like it cannot fetch files outside the wine directory structure? if yes then how should i format my directory address if i move the EA file inside mt5 directory?

Here are the log file contents
image

Is it like it cannot fetch files outside the wine directory structure?

It's limitation of the platform (by design and for safety also). Basically path needs to be relative to MQL5/Experts/.

Official platforms' CLI docs: https://www.metatrader5.com/en/terminal/help/start_advanced/start

You'll have to create your own play or script to upload your EA at the right location (after platform install), at least at this point, as I haven't thought about it yet. This functionality of copy of EA file can be added at some point, if it's going to be useful.

Re: EA copy feature. Implementing copying of EA file comes with different scenarios, as you can have a startup EA to run (StartUp/Expert), EA to test (Tester/Expert), a script file (StartUp/Script), so 3 different files multiply by 2 supported platforms (4&5), there are at least 6 combinations how and were you should copy the file (each should be copied into different dir), so we'll have to have some kind of array to know which type of file goes to where (even based on the extension, it's still ambiguous whether it's EA file or a script). So it's something to think whether this should be part of this role and can be implemented simply enough.

Here is an example how to copy a file just using Ansible command:

ansible all -m copy -a "src=myfile.ex5 dest=/home/ubuntu/.wine/somewhere/myfile.ex5 owner=root group=root mode=0644" -i hosts -b

In case MQL5/Experts/ doesn't exist yet, you've to create it manually, or run platform for the first time, so the initial structure can be created by the platform, then copy the file.

  • Mentioned issues have been now fixed in dev branch.
  • Fetching EA into directory has been added as well.

E.g. to download EA into Experts dir, you can define the following variable:

    mt_runner_get_url_list:
     - dest: "{{ mt_runner_mt_path }}/MQL5/Experts"
       url: https://example.com/EA.ex5

For the working example and usage, please check: https://colab.research.google.com/drive/1ybsqnVANuiJBdnza47e9VRIYFK4E1xKZ

To install this role from dev branch, run:

ansible-galaxy install git+https://github.com/EA31337/ansible-role-mt-runner.git,dev