Comments (4)
I would be interested in that too, that's the main reason why I tried denon. As I was hoping the app would also automatically restart in watch mode when it crashes, as this doesn't work with the normal --watch parameter either.
The app stops with this message:
app crashed - waiting for file changes before starting ...
from denon.
@ralyodio Until there is a clean solution here is a workaround, I have write a simple script that checks if my deno webserver is still running, if not it restarts the app using pm2.
Maybe this is not a solution for you, because pm2 uses node.js instead of deno and you need a webserver in your app.
health-checker.ts:
const BACKEND_LOCAL_URL = "http://localhost:3000";
let interval: number | null = null;
const restart = () => {
console.log("Restart app..");
Deno.run({ cmd: ["pm2", "restart", "your-pm2-instance-name"] });
if (interval) clearInterval(interval);
startWatch();
}
const startWatchInterval = (watchInterval: number) => {
interval = setInterval(async () => {
try {
const state = await fetch(BACKEND_LOCAL_URL);
if (!state.ok) {
restart();
} else {
console.log(`ok, next check in ${watchInterval}ms..`);
}
} catch (error) {
console.error(error);
restart();
}
}, watchInterval);
}
const startWatch = (startDelay=15000, watchInterval=5000) => {
console.log(`Start watcher in ${startDelay}ms..`);
setTimeout(() => {
startWatchInterval(watchInterval);
}, startDelay)
}
startWatch();
Maybe you can replace the Deno.run
command with something else.
pm2.config.js:
module.exports = {
apps: [
{
name: "your-pm2-instance-name",
script: "denon watch",
},
],
};
Start this with:
pm2 start ./pm2.config.js
scripts.json:
{
"$schema": "https://deno.land/x/[email protected]/schema.json",
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Start the webserver",
"watch": false
},
"watch": {
"cmd": "deno run app.ts",
"desc": "Watch the webserver",
"watch": true
},
"health-checker": {
"cmd": "deno run health-checker.ts",
"desc": "Run the health checker to restart the webserver on a crash",
"allow": ["net", "run"],
"watch": true
}
}
}
Start the health-checker with:
denon health-checker
pm2 will start the web server with denon watch
for us and the health-checker restarts the web server using pm2.
from denon.
I stopped using denon. systemd will recover itself when deno crashes so no need for denon in prod.
its handy for local dev but this package seems to be rather broken now for awhile.
from denon.
If anyone looks for an up to date answer, have a look at http://github.com/hexagon/pup
from denon.
Related Issues (20)
- Nothing works with Deno 1.14+ HOT 2
- Compatibility with Deno v1.15.3 HOT 4
- Nothing works with Deno 1.16.0 HOT 4
- Denon Daemon Error when running on Deno 1.16.1 HOT 5
- rename `importmap` to `importMap`
- allow `scripts.ts` and `scripts.js`
- I can't install DENON HOT 10
- Can't install "Denon" Deno "1.17.1" HOT 11
- Outdated schema.json on deno.land
- Live Reload-ish first class support for Denon?
- Denon install error HOT 3
- No such file or directory (os error 2)
- Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'SIGHUP') HOT 1
- error: Uncaught Error: Import 'https://deno.land/x/denon@$%7BVERSION%7D/mod.ts' failed: 404 Not Found
- Restart when app crashed. HOT 1
- Default script option for `denon`
- Uncaught SyntaxError
- Nest CDN isn't available
- No LevelName export in ./levels.ts ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from denon.