Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow custom startup commands

See original GitHub issue

Is your feature request related to a problem? Please describe.

When starting the emulator with a dev server, we need to start the dev server separately before starting swa.

Describe the solution you’d like

Allow an app startup command and working folder to be provided. The emulator starts the command before proceeding. For example, running a startup command in the frontend folder might look like this:

swa start http://localhost:3000 --app-startup-command "npm start" --app-location ./frontend

Or if we can make this work cross platform:

swa start http://localhost:3000 --app-startup-command "cd frontend && npm start"

Perhaps also support --api-startup-command? Not sure if this is needed right now.

Describe alternatives you’ve considered

Start the process separately.

Additional context

Also needs this functionality as we have to wait for the servers to be up before proceeding: #146

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

anthonychucommented, Apr 1, 2021

I think there’s a different between “build” and “run”/“startup command”. Build implies run to completion, then start emulator. The command I’m looking for is run and start emulator when port is available. So I think this would work better as something other than a build command.

manekinekkocommented, Apr 8, 2021

Good catch! What’s happening here is that when we start with a dev server context (swa start http://localhost:3000 ...), we await (waitOn) for that dev server to be ready before moving on.

This process will block the rest of the script and hence we don’t reach the --run logic. The CLI will exit(-1) after waitOn times out.

To fix this, I suggest that we skip awaiting for the dev server if we are also passing in a --run command. This way we:

  1. start swa and setup the proxy requests for the dev server
  2. in parallel, we process the --run command (which for instance starts the dev server)

However, if we follow this logic, then running the following command swa start http://localhost:3000 --run "echo Hey", where the --run script doesn’t start a dev server, then all proxied requests to http://localhost:3000 will fail if the dev server isn’t started. (and we skipped checking if the dev server is ready).

On the other hand, if we don’t passe in a --run script, then we will have to await for the dev server to be ready (what we are doing rn).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Enable Custom Startup Parameters on Your ARK Server
ENABLING CUSTOM STARTUP PARAMTERS. Log in to your server's FTP (Files > FTP File Access) and click Edit next to the file....
Read more >
How to Run a Command on Startup in Linux
1. Put the command in your crontab file. The crontab file in Linux is a daemon that performs user-edited tasks at specific times...
Read more >
Take control of your Windows start-up - Microsoft Support
1. From the Run command, open Msconfig. This opens the application to the General tab, as shown above. · 2. Click the Startup...
Read more >
New Setting to configure a startup command for each pane of ...
I would like to be able to configure a specific command to run at startup, for each pane of a custom display I...
Read more >
Where and how are custom startup commands configured in ...
Under Debian (and Debian-based system such as Ubuntu), you put your startup script called foo to the directory /etc/init.d , then you call ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found