docker-compose up throws SyntaxError: Invalid or unexpected token
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
What's going wrong?
I'm trying to start a service using docker-compose up, but pm2 is not able to execute docker-compose file. docker-compose up command runs fine if I execute it manually, it just fails when pm2 executes it
pm2 log 0
[TAILING] Tailing last 15 lines for [0] process (change the value with --lines option)
/home/gharsnull/.pm2/logs/docker-services-out.log last 15 lines:
/home/gharsnull/.pm2/logs/docker-services-error.log last 15 lines:
0|docker-s | /usr/bin/docker-compose:2
0|docker-s | # EASY-INSTALL-ENTRY-SCRIPT: 'docker-compose==1.29.2','console_scripts','docker-compose'
0|docker-s | ^
0|docker-s |
0|docker-s | SyntaxError: Invalid or unexpected token
0|docker-s | at wrapSafe (internal/modules/cjs/loader.js:1001:16)
0|docker-s | at Module._compile (internal/modules/cjs/loader.js:1049:27)
0|docker-s | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
0|docker-s | at Module.load (internal/modules/cjs/loader.js:950:32)
0|docker-s | at Function.Module._load (internal/modules/cjs/loader.js:790:12)
0|docker-s | at Object.<anonymous> (/home/gharsnull/.nvm/versions/node/v14.20.1/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
0|docker-s | at Module._compile (internal/modules/cjs/loader.js:1085:14)
0|docker-s | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
0|docker-s | at Module.load (internal/modules/cjs/loader.js:950:32)
0|docker-s | at Function.Module._load (internal/modules/cjs/loader.js:790:12)
Supporting information
npm --version
6.14.17
node --version
v14.20.1
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
ecosystem.config.js
module.exports = {
apps: [
{
name: 'docker-services',
cwd: './docker',
script: 'docker-compose',
args: 'up',
kill_timeout: 100000,
},
],
};
#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'docker-compose==1.29.2','console_scripts','docker-compose'
import re
import sys
# for compatibility with easy_install; see #2198
__requires__ = 'docker-compose==1.29.2'
try:
from importlib.metadata import distribution
except ImportError:
try:
from importlib_metadata import distribution
except ImportError:
from pkg_resources import load_entry_point
def importlib_load_entry_point(spec, group, name):
dist_name, _, _ = spec.partition('==')
matches = (
entry_point
for entry_point in distribution(dist_name).entry_points
if entry_point.group == group and entry_point.name == name
)
return next(matches).load()
globals().setdefault('load_entry_point', importlib_load_entry_point)
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
--- PM2 report ----------------------------------------------------------------
Date : Fri Oct 21 2022 11:14:54 GMT-0500 (Colombia Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.2.2
node version : 14.20.1
node path : /home/gharsnull/.nvm/versions/node/v14.20.1/bin/pm2
argv : /home/gharsnull/.nvm/versions/node/v14.20.1/bin/node,/home/gharsnull/.nvm/versions/node/v14.20.1/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : gharsnull
uid : 1000
gid : 1000
uptime : 21min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.2.2
node version : 14.20.1
node path : /home/gharsnull/.nvm/versions/node/v14.20.1/bin/pm2
argv : /home/gharsnull/.nvm/versions/node/v14.20.1/bin/node,/home/gharsnull/.nvm/versions/node/v14.20.1/bin/pm2,report
argv0 : node
user : gharsnull
uid : 1000
gid : 1000
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : AMD Ryzen 5 5600X 6-Core Processor
cpus nb : 12
freemem : 1839833088
totalmem : 16692473856
home : /home/gharsnull
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ docker-services │ default │ N/A │ fork │ 0 │ 0 │ 30 │ errored │ 0% │ 0b │ gha… │ disabled │
│ 3 │ document-service-be │ default │ 0.39.2 │ fork │ 13558 │ 6s │ 15 │ online │ 0% │ 55.6mb │ gha… │ disabled │
│ 1 │ main-be │ default │ 0.39.2 │ fork │ 11644 │ 6m │ 0 │ online │ 0% │ 47.5mb │ gha… │ disabled │
│ 2 │ main-fe │ default │ 0.39.2 │ fork │ 11652 │ 6m │ 0 │ online │ 0.2% │ 48.1mb │ gha… │ disabled │
└─────┴────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list is not synchronized with saved list. Type 'pm2 save' to synchronize.
===============================================================================
--- Daemon logs --------------------------------------------
/home/gharsnull/.pm2/pm2.log last 20 lines:
PM2 | 2022-10-21T11:11:29: PM2 log: App [document-service-be:3] starting in -fork mode-
PM2 | 2022-10-21T11:11:29: PM2 log: App [document-service-be:3] online
PM2 | 2022-10-21T11:12:02: PM2 log: App [document-service-be:3] exited with code [255] via signal [SIGINT]
PM2 | 2022-10-21T11:12:02: PM2 log: App [document-service-be:3] starting in -fork mode-
PM2 | 2022-10-21T11:12:02: PM2 log: App [document-service-be:3] online
PM2 | 2022-10-21T11:12:35: PM2 log: App [document-service-be:3] exited with code [255] via signal [SIGINT]
PM2 | 2022-10-21T11:12:35: PM2 log: App [document-service-be:3] starting in -fork mode-
PM2 | 2022-10-21T11:12:35: PM2 log: App [document-service-be:3] online
PM2 | 2022-10-21T11:13:09: PM2 log: App [document-service-be:3] exited with code [255] via signal [SIGINT]
PM2 | 2022-10-21T11:13:09: PM2 log: App [document-service-be:3] starting in -fork mode-
PM2 | 2022-10-21T11:13:09: PM2 log: App [document-service-be:3] online
PM2 | 2022-10-21T11:13:42: PM2 log: App [document-service-be:3] exited with code [255] via signal [SIGINT]
PM2 | 2022-10-21T11:13:42: PM2 log: App [document-service-be:3] starting in -fork mode-
PM2 | 2022-10-21T11:13:42: PM2 log: App [document-service-be:3] online
PM2 | 2022-10-21T11:14:15: PM2 log: App [document-service-be:3] exited with code [255] via signal [SIGINT]
PM2 | 2022-10-21T11:14:15: PM2 log: App [document-service-be:3] starting in -fork mode-
PM2 | 2022-10-21T11:14:15: PM2 log: App [document-service-be:3] online
PM2 | 2022-10-21T11:14:48: PM2 log: App [document-service-be:3] exited with code [255] via signal [SIGINT]
PM2 | 2022-10-21T11:14:48: PM2 log: App [document-service-be:3] starting in -fork mode-
PM2 | 2022-10-21T11:14:48: PM2 log: App [document-service-be:3] online
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ecosystem.config.js and the PM2 stack trace at lib/ProcessContainerFork.js, then compare how PM2 launches the /usr/bin/docker-compose entry script with running docker-compose manually. Done means the supplied configuration starts docker-compose under PM2 without Node reporting a SyntaxError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, javascript, nodejs
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100