ACLClouds
ACLClouds

How do I modify the startup command?

Choose the bot’s entry file or start command from the “Startup” tab. Prefer a stable start script to a long command that is hard to maintain.

The “Startup” tab shows the startup command and the variables it uses, such as the “Main file”. Prefer a stable start script to a long command that is hard to maintain.

Step-by-step procedure

  1. Identify the main file

    Locate src/index.js, app.js, bot.py or the entry point declared by your project.

  2. Define a script

    In Node.js, add a start script in package.json. In Python, keep a simple command to the main module.

  3. Edit variable

    In Startup, change the “Main file”, or click “Edit” in “Startup command” and then “Save”. The change applies at the next start.

  4. Check the console

    A “file not found” error means that the path or case does not match the file present.

Node.js scripts

"scripts": {
  "start": "node src/index.js"
}

start script that chains two steps

"scripts": {
  "start": "node deploy-commands.js && node src/index.js"
}

How the command is built

For a Node.js bot, the default command is node {{MAIN_FILE}} {{NODE_ARGS}}; for Python, python -u {{PY_FILE}}. At launch, each variable in braces is replaced by its value. The “Startup command” card shows the command with those values already filled in.

The “Main file” (MAIN_FILE or PY_FILE) is enough in most cases: enter a path relative to the root of the files, for example src/index.js. The “Bot arguments” (NODE_ARGS) are added after the file and read by your code in process.argv.

Writing a custom command

“Edit” opens the raw command, with its variables in braces. It fits on a single line of at most 255 characters and runs a single program: &&, ;, | and quotes are not interpreted. To chain several steps, put them in the start script of package.json and use npm start as the command.

A hand-written command is kept as it is: the “Main file” only has an effect if the command contains {{MAIN_FILE}}. To go back to the original setup, click “Reset all”: the default command is rebuilt with the main file found in your files, the options return to their default values and tokens are left untouched.

Checking the command that runs

Restart the bot from the console. After “Server marked as starting”, a line beginning with $ shows the command actually run, for example $ node src/index.js. If the path does not match, compare it with the “Files” tab, including case: Index.js and index.js are two different files on Linux.

Frequently asked questions

Why doesn’t cd src && node index.js work?

The command is not interpreted by a shell: && becomes a plain argument and cd cannot be used there. Give the path directly, node src/index.js, or put the sequence in the start script of package.json and set npm start as the command.

Is npm start or node index.js better?

Without a saved command, a start script that is just node index.js is launched directly, with no npm process in front of the bot: startup is faster and shutdown cleaner. Keep npm start when the script chains several steps, such as registering slash commands before logging in.

How do I pass an option to Node.js, such as a memory limit?

The NODE_OPTIONS variable is reserved: write the option in the command, before the file, for example node --max-old-space-size=256 src/index.js. Placed after the file, it would be passed to your code, not to Node.js.

I changed the command but the bot still runs the old one: why?

The command applies at the next start: restart the bot from the console. After “Save”, the message “The startup command has been updated.” confirms it was saved.