Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too bad it is no longer update. I like it is simple and direct. I have added starting IB gateway in Ubuntu if anyone like it too. #33

Open
tonsmons opened this issue May 24, 2023 · 0 comments

Comments

@tonsmons
Copy link

tonsmons commented May 24, 2023

client.py

@@ -527,8 +552,37 @@
                 args=IB_WEB_API_PROC,
                 cwd=self.client_portal_folder
             ).pid
-
-        return self.server_process
+
+        elif self._operating_system == 'linux':
+            IB_WEB_API_PROC = [self.client_portal_folder+r"/bin/run.sh",r"root/conf.yaml"]
+            process = subprocess.Popen(
+                args=IB_WEB_API_PROC,
+                cwd=self.client_portal_folder,
+                stdout=subprocess.PIPE, universal_newlines=True
+            ).pid
+            time.sleep(2)
+            # get the right process by psutil, the above process takes the pid from run.sh, not the java one
+            for proc in psutil.process_iter():
+                try:
+                    processID = proc.pid
+                    # processName = proc.name()
+                    cmd = proc.cmdline()
+                    if any(r"root/conf.yaml" in s for s in cmd) and not any('run.sh' in s for s in cmd):
+                        self.server_process = processID
+                        break
+                except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
+                    pass
+            # keep alive process
+            IB_WEB_ALIVE = r'while true; do /usr/bin/sleep 300; /usr/bin/curl -ks '+self.ib_gateway_path+'/v1/portal/tickle; done'
+            self.server_alive = subprocess.Popen(args=[IB_WEB_ALIVE], shell=True).pid
+
+        return self.server_process,self.server_alive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant