question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Restarting server on changes

See original GitHub issue

Description

Is there anyway to start/ stop/ restart the server during test?

Expected outcome

to start separate server to run jasmine tests then stop the server after test complete

Actual outcome

Not sure how to stop server other than usual CTRL + C command

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
franciscopcommented, Sep 18, 2021

So I had big plans for Server.js (large overhauls, big plugin system) but then started working fulltime in a demanding job so now it’s in maintenance[1]. Everything there should work, but I’m not rewriting/making large changes to it for the time being. I still do some experiments from time to time.

One large issue with server.js is that I never thought too well is how devs would test their apps running this library. I’ve since learned and in my recent projects I even include examples for testing.

Another thing is that, when I eventually build server.js 1.1 or 2.0, I want the APIs to be mostly backwards compatible (even if 2.0 implies breaking changes, I’m trying to minimize those). So any API that I’m not completely sure, I think it’s best not to have it officially supported.

So yeah, you can definitely use server().then(ctx => ctx.close()) if you want; I’m using it in fact, but I’m not comfortable making that single function official until there’s a whole story on testing. In fact, there are two large parts that are unfinished, one is testing and another is error handling (or better said, the documentation about error handling):

That said, I just added a small note in Advanced Topics about server().then(app => app.close()) (and named it app to avoid confusing it with the normal middleware context).

[1] The main reason, while I’ve been doing other projects, is scale. Server.js (along with probably Picnic CSS) is probably the largest and most complex project I’ve built. To do small but important new features/changes it takes dozens of hours (I am very strict on not breaking things in this project), which I still do (see the new head() method), and to give the love the project needs to be 1st class it’d require few months of full time work IMHO. I simply don’t have that time/energy right now, I hope to have it in the future but as right now I’m just doing my best to maintain the project.

0reactions
mindplay-dkcommented, Sep 17, 2021

To answer your question, yes there is as @SidneyNemzer mentioned. However this is not a production-ready method and might change in the future, so please use with care (note: it will probably not change, but only the documented API should be considered stable).

However please note that close() will return a promise

Conclusion

As soon as I figure out how to fix these two issues and test it enough, I will release run for production, with its documentation and tests.

What’s the status on this one?

I just discovered server.js and immediately loved the elegant, minimal API - looks perfect for testing on my project, and frankly I’d prefer not to mess around with express, either by itself, or by breaking into the implementation details of server.js.

I looked everywhere in the manual for some way to stop a server - but context.close() remains undocumented 3 years later?

There is a list of useful issues and caveats in this issue - these would make good work items… and the issue doesn’t appear to have been (officially) resolved, so I would suggest to reopen this, if you wouldn’t mind?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatically Restart Node Apps on File Change with nodemon
In this short tutorial, learn how to restart Node/JavaScript applications automatically when you change a source file with Nodemon.
Read more >
Is a server reboot a change - ITILfromExperience.com
A reboot does not change the configuration of the service or the attributes of the configuration items thus, it is not a change...
Read more >
When the test server requires restarting - IBM
If you change the server or the server configuration while the server is running, for example, if you change the port number, you...
Read more >
Configuration Changes Requiring Server Restart
If a property has an rws (read, write, static) keyword, the server must be restarted when the property is changed. If a property...
Read more >
Automatically restart Node.js apps with Nodemon
The essential tutorial for Nodemon, a utility for Node.js applications that monitors for changes and automatically restarts the server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found