-
Install npm: Open your terminal and type
npm install, which will install the Node Package Manager. -
Create the
shadowrocketdirectory: Usemkdir shadowrocketto create the necessary directory. -
Create the
config.jsonfile: Usenpm createwith the configuration data. For example:npm create config.json
This will create a JSON file named
config.jsonin theshadowrocketdirectory. -
Create the
run.shscript: Write a bash script in theshadowrocket/run.shfile. It should look something like this:#!/bin/bash echo "Starting run script..." rm -f "$(echo 'shadowrocket/ $1' | cut -d/ -f2)" echo "Scripting: /bin/bash" echo "Starting at: $1" echo "Please enter the script name:" echo "1: web" echo "2: command-line" read script_name= $(echo 'web' | cut -d/ -f2) if [ $script_name = 1 ]; then echo "Starting a web server..." cd /bin export PATH=/bin npm run dev:web else echo "Starting a command-line script..." cd /bin npm run start fi
This script will start a web server or a command-line application based on the script name.
-
Run the script in the background: Use the
backgroundcommand to execute the script:background -f run.sh
This will run the script in the
shadowrocket/run.shfile in the background. -
Handle errors: Shadowrocket typically stops execution if an error occurs. To capture output, use the logger:
logger.add
You can also check the error message if it appears.
-
Organize applications: Consider creating subdirectories for different types of applications, such as
webfor web apps andcommand-linefor command-line tools, to keep things organized. -
Permissions: Ensure the
shadowrocketdirectory has write permissions. Use a virtual environment with Node.js and install npm.
By following these steps, you can set up Shadowrocket and run a script to execute in the background.









