Ionic Server doesn't shutdown gracefully using Cordova


#1

I have to build an ionic cordova app. So I prepared my macOS with all needed utilities. First I have to create the app on the browser platform. Therefore I start the process with “ionic cordova run browser”. After testing I just want to shutdown the server with crtl+c, but even a node process will be left. So every time I would have to kill the process using the command line tool “kill”. It isn’t really comfortable.

I found out if I run only the command “cordova run browser” without an ionic build the server is shutting down correctly. The same thing, if I run “ionic serve” without using cordova. Additionally my “ionic info” output:

cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:
cordova (Cordova CLI) : 8.0.0

local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : browser 5.0.3
Ionic Framework : ionic-angular 3.9.2

System:
ios-deploy : 1.9.1
Node : v8.10.0
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.2 Build version 9C40b

Environment Variables:
ANDROID_HOME : not set

Misc:
backend : legacy


#2

I’m having this problem too. When I run ionic cordova run browser --port 8100 it opens a browser window and displays my app, but it is being accessed on port 8000, not 8100. It seems to ignore the --port option. I noticed the following output after the build process:

Running command: "/path/to/application/platforms/browser/cordova/run" --nobuild

Static file server running @ http://localhost:8000/index.html

Furthermore, when I stop the server with Ctrl+C, it seems to still be running on port 8000. I have to stop it manually with kill.

Ionic info output:

cli packages: (/path/to/environment/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 6.4.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : browser 4.1.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.0
    ios-sim    : 5.0.8
    Node       : v8.10.0
    npm        : 5.6.0
    OS         : macOS Sierra
    Xcode      : Xcode 9.1 Build version 9B55

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

EDIT
I found that I could set the port with ionic cordova run browser -- --port=8100, but stopping the server with Ctrl+C still does not kill the server. This worked after upgrading the Cordova CLI to 8.0.0.


#3

Ionic CLI issues can be reported here: https://github.com/ionic-team/ionic-cli/issues