Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supervisor not working as expected after upgrading from Foal 2 to Foal 4 #1258

Open
lcnvdl opened this issue Apr 25, 2024 · 7 comments
Open
Assignees
Labels

Comments

@lcnvdl
Copy link
Contributor

lcnvdl commented Apr 25, 2024

I'm developing a micro-services backend using Foal TS.

In the development environment, I use a "multiple console" runner. I launch every service at the same time.

The problem is that when I run the Foal 4 projects, it never starts, I have to reboot manually the services until it starts working. And, also, it takes sometimes like 10 minutes.

In the next image: Metr is working, Coord, Cred, High, Iden, Logg, Stge and Stor are not working. Mail and Func are not FoalTS services, so please ignore them.

image

That is not what happens if I run all the Foal V2 projects.

In the next image: All services are working.

image

I'm sure the problem is Supervisor, because the problem was fixed after replacing it with another tool (a popular tool named nodemon).

https://www.npmjs.com/package/nodemon

This not only solves the problem, but also starts the project faster.

My new command for npm run dev is:

{
"dev": "npm run build && concurrently -r \"tsc -p tsconfig.app.json -w\" \"nodemon --delay 2 -w ./build -w ./config -e js,json,yml ./build/index.js\"",
}
@lcnvdl lcnvdl added the bug label Apr 25, 2024
@LoicPoullain
Copy link
Member

Which version of supervisor did you have in Foal 2 and in Foal 4?

Also, what was the command in package.json in Foal 2 and in Foal 4?

@lcnvdl
Copy link
Contributor Author

lcnvdl commented Apr 25, 2024

Foal TS 2 command:

{
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build,./config -e js,json,yml --no-restart-on error ./build/index.js\"",
}

Supervisor version:

{
"supervisor": "~0.12.0",
}

Note: I didn't realize that the only difference was the command, I thought they were different versions too

@lcnvdl
Copy link
Contributor Author

lcnvdl commented Apr 25, 2024

I was researching. Supervisor not only is less popular than Nodemon, also, is not mantained:

image

image

Vs nodemon:

image

image

Maybe replacing Supervisor is a good idea.

If you want, I can send you a pull request.

@LoicPoullain
Copy link
Member

LoicPoullain commented Apr 26, 2024

Out of curiosity, what operating system are you running?

The reasons why supervisor was chosen in the first place rather than nodemon were the following:

  • It has 0 dependencies (and sub-dependencies) which has many advantages like a smaller size of the node_modules directory, fewer trouble to deal with when a sub-dependency suddenly breaks things in a minor version, and fewer security vulnerabilities to patch.
  • And, at the time, when installing nodemon, a message was displayed in the terminal asking users to donate money/sponsors to the project, which sort of "polluted" the installation output.

But perhaps this is something that no longer applies:

  • As you pointed out, supervisor seems no longer to be maintained, which could lead to problems in the future (unpatched vulnerabilities, new versions of Node not being supported).
  • Installation of nodemon no longer displays a "money message".
  • The output of npm run dev is more "beautiful" with nodemon.
  • And nodemon starts the project faster (based on what you said).

(I don't think popularity is a good criterion for choice though.)

An alternative, which I hope will work one day, would be to use the native node --watch function. Unfortunately, the --watch-path option doesn't work on Linux at the moment.

Moving to nodemon seems to be an interesting choice then, do you want to submit a PR?

They are some stuff that should still work though:

  • when a file config file in JSON or YAML is changed, the server should restart,
  • when an error is thrown when the server start, the server should not be reloaded indefinitely,
  • doc examples with gRPC and GraphQL should be updated and still work.

@LoicPoullain LoicPoullain added this to Backlog in Issue tracking via automation Apr 26, 2024
@LoicPoullain
Copy link
Member

LoicPoullain commented Apr 26, 2024

@lcnvdl if you take this one, I'd recommend to start with a completely new fork and "checkouts" your feature branch from v4-5-0. The dependency system has been updated in this branch and it will be easier to run npm install nodemon and npm uninstall supervisor in @foal/examples.

@lcnvdl
Copy link
Contributor Author

lcnvdl commented Apr 29, 2024

Thank you for your answer.

Out of curiosity, what operating system are you running?

Windows 11

The reasons why supervisor was chosen in the first place rather than nodemon were the following:

  • It has 0 dependencies (and sub-dependencies) which has many advantages like a smaller size of the node_modules directory, fewer trouble to deal with when a sub-dependency suddenly breaks things in a minor version, and fewer security vulnerabilities to patch.

I understand your reasons.

  • And, at the time, when installing nodemon, a message was displayed in the terminal asking users to donate money/sponsors to the project, which sort of "polluted" the installation output.

But perhaps this is something that no longer applies:

  • As you pointed out, supervisor seems no longer to be maintained, which could lead to problems in the future (unpatched vulnerabilities, new versions of Node not being supported).
  • Installation of nodemon no longer displays a "money message".
  • The output of npm run dev is more "beautiful" with nodemon.
  • And nodemon starts the project faster (based on what you said).

(I don't think popularity is a good criterion for choice though.)

An alternative, which I hope will work one day, would be to use the native node --watch function. Unfortunately, the --watch-path option doesn't work on Linux at the moment.

Moving to nodemon seems to be an interesting choice then, do you want to submit a PR?

Sure!

They are some stuff that should still work though:

  • when a file config file in JSON or YAML is changed, the server should restart,

Ok

  • when an error is thrown when the server start, the server should not be reloaded indefinitely,

Ok

  • doc examples with gRPC and GraphQL should be updated and still work.

Ok, I never tried that examples, but I will run them before and after the change, in order to get the same results.

@lcnvdl
Copy link
Contributor Author

lcnvdl commented Apr 29, 2024

I'd recommend to start with a completely new fork and "checkouts" your feature branch from

Sure! Thanks for the information

@LoicPoullain LoicPoullain moved this from Backlog to Work In Progress in Issue tracking Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Issue tracking
  
Work In Progress
Development

No branches or pull requests

2 participants