Last active
October 24, 2024 03:00
-
-
Save revant/18f456c1d136858bf9c132dc6fd7a167 to your computer and use it in GitHub Desktop.
Use node server with frappe-bench
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// content of custom_node.js | |
const http = require('http') | |
const port = 4200 | |
const requestHandler = (request, response) => { | |
console.log(request.url) | |
response.end('Hello Node.js Server!') | |
} | |
const server = http.createServer(requestHandler) | |
server.listen(port, (err) => { | |
if (err) { | |
return console.log('something bad happened', err) | |
} | |
console.log(`server is listening on ${port}`) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream frappe-bench-custom-node { | |
server 0.0.0.0:4200 fail_timeout=0; | |
} | |
server { | |
... | |
location /custom-node { | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header X-Frappe-Site-Name test_rn; | |
proxy_set_header Origin $scheme://$http_host; | |
proxy_set_header Host $host; | |
proxy_pass http://frappe-bench-custom-node; | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redis_cache: redis-server config/redis_cache.conf | |
redis_socketio: redis-server config/redis_socketio.conf | |
redis_queue: redis-server config/redis_queue.conf | |
web: bench serve --port 8000 | |
socketio: /usr/bin/node apps/frappe/socketio.js | |
custom_app: /usr/bin/node apps/custom_app/custom_node.js | |
watch: bench watch | |
schedule: bench schedule | |
worker_short: bench worker --queue short | |
worker_long: bench worker --queue long | |
worker_default: bench worker --queue default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Notes: | |
; priority=1 --> Lower priorities indicate programs that start first and shut down last | |
; killasgroup=true --> send kill signal to child processes too | |
[program:frappe-bench-custom-app] | |
command=/usr/bin/node /home/revant/frappe-bench/apps/custom_app/custom_node.js | |
priority=4 | |
autostart=true | |
autorestart=true | |
stdout_logfile=/home/revant/frappe-bench/logs/custom-app.log | |
stderr_logfile=/home/revant/frappe-bench/logs/custom-app.error.log | |
user=revant | |
directory=/home/revant/frappe-bench | |
[group:frappe-bench-extras] | |
programs=frappe-bench-custom-app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment