I have a node+angular app. It was working fine. I had an issue which was eaddrinuse 3000 . I run this command killall node and guess what my app which was working on x.x.x.x:8100 is not working any more.I am using bitvise by the way.
This is my directory structure. I am doing this on production server.
--app
| ---assets
---bower_components
---directives
---home
---misc
---product
---services
---user
---index.html
--backend
| ---img
---models
---node_modules
---public
---routes
---app.js
---package.json
--package.json (frontend)
Related
I have a project. Although it is the same website, the front and back ends are divided into 2 repo(s), which are made by React and Ruby on Rails respectively. Therefore, every time I want to start a website locally, I must open 2 Ubuntu terminal windows.
I heard that foreman can start both at once. Are there any examples to learn from? Thanks!
You could just add foreman gem to you Gemfile and create Procfile.dev file in your root directory.
Inside of it, you add all of the processes you want to launch. So, it could be something like this:
backend: bin/rails server -p 3000
frontend: npm start
Obviously, you can use whatever you use to start your frontend application.
And then you run foreman start -f Procfile.dev in your terminal.
My react app is in the directory /home/ubuntu/my-app, the home directory being /home/ubuntu. I am using an AWS ec2 instance and I want the react script to execute whenever the server is starting. For this purpose, I wrote the following script:
#!/usr/bin/python3
import os
import time
import shlex, subprocess
time.sleep(20)
args = shlex.split('sudo su ubuntu -c "/usr/bin/npm start --prefix /home/ubuntu/my-app"')
subprocess.Popen(args)
When I run the script manually with ./react-start.py everything works just fine. However, when I reboot the AWS instance, I get the following log:
> my-app#0.1.0 start /home/ubuntu/my-app
> react-scripts start
^[[34mℹ^[[39m ^[[90m「wds」^[[39m: Project is running at http://172.31.14.57/
^[[34mℹ^[[39m ^[[90m「wds」^[[39m: webpack output is served from
^[[34mℹ^[[39m ^[[90m「wds」^[[39m: Content not from webpack is served from /home/>
^[[34mℹ^[[39m ^[[90m「wds」^[[39m: 404s will fallback to /
Starting the development server...
..and nothing happens.
I am using crontab to call the script at reboot by the way. Does anyone have an idea why it's not working? Thanks a lot!
I have an reactjs application that I have deploy on my web server.
I build my app (So it's create a build folder) and when I want to start it with ~/.npm-packages/bin/serve -s ./build -l tcp://0.0.0.0:8100 it work (with work dir set to react/, build is here react/build but we can see all source code on my page, that theory not possible in production mode.
If I set the work dir to react/build it return a 404 error.
Inside build folder
It doesn't return any other error unfortunately.
Update: I only stock build folder and it work, but we can always see source code even its in production mode.
If I change to react/build, react/build/static or other, it display 404.
If you are using npm's serve (the default for create-react-app, which I am assuming you are using), that second argument is the directory to serve:
$ serve --help
$ serve} [-l listen_uri [-l ...]] [directory]
By default, serve will listen on 0.0.0.0:5000 and serve the
current working directory on that address.
-s, --single Rewrite all not-found requests to `index.html`
But serve is meant for development serving. It works fine for production of a small static site, but consider another production-proven web server.
Your unminified source should not be kept on a production server, at all. You should deploy just the build files to production.
I've built a docker image which consists of two parts:
simple nodejs app which is listening to port 8080
haskell service which is using snap framework (port 8000)
I know that it's better to run those two parts in different containers, but there is a reason to keep them in one. So I found a way how to run two services in one container with the use of supervisord.
In the dockerfile I expose 8080, and when I run the docker image locally it works just fine. I can make POST requests to nodejs app, which in its turn is making POST request to the haskellmodule using port 8000. I run it with the following command:
docker run -p 8080:8080 image_name
So I pushed the image to google container registry and deployed it with the use of --image-url flag. The deployment process goes without any error, though after that I cannot reach my app. If I look to the running version's logs, I see the following:
A /usr/lib/python2.7/dist-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
A 'Supervisord is running as root and it is searching '
A 2017-10-08 14:08:45,368 CRIT Supervisor running as root (no user in config file)
A 2017-10-08 14:08:45,368 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
A 2017-10-08 14:08:45,423 INFO RPC interface 'supervisor' initialized
A 2017-10-08 14:08:45,423 CRIT Server 'unix_http_server' running without any HTTP authentication checking
A 2017-10-08 14:08:45,424 INFO supervisord started with pid 1
A 2017-10-08 14:08:46,425 INFO spawned: 'haskellmodule' with pid 7
A 2017-10-08 14:08:46,427 INFO spawned: 'nodesrv' with pid 8
A 2017-10-08 14:08:47,429 INFO success: haskellmodule entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
A 2017-10-08 14:08:47,429 INFO success: nodesrv entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
A 2017-10-08 14:13:49,124 WARN received SIGTERM indicating exit request
A 2017-10-08 14:13:49,127 INFO waiting for haskellmodule, nodesrv to die
A 2017-10-08 14:13:49,128 INFO stopped: nodesrv (terminated by SIGTERM)
A 2017-10-08 14:13:49,138 INFO stopped: haskellmodule (terminated by SIGTERM)
Then it starts over and everything is repeated over and over again.
My Dockerfile:
FROM node:latest
RUN apt-get update
RUN curl -sSL https://get.haskellstack.org/ | sh
COPY ./nodesrv /nodesrv
COPY ./haskellmodule /haskellmodule
RUN mkdir /log
WORKDIR /haskellmodule
RUN stack build
WORKDIR /
RUN apt-get update && apt-get install -y supervisor
ADD ./configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 8080
ENTRYPOINT ["/usr/bin/supervisord"]
My supervisord config:
[supervisord]
nodaemon=true
[program:nodesrv]
command=node index.js
directory=/nodesrv/
user=root
[program:haskellmodule]
command=stack exec haskellmodule-exe
directory=/haskellmodule/
user=root
My app.yaml file I use for deployment:
runtime: custom
env: flex
So seems like google app engine is shutting supervisor down (taking into account that everything is working on localhost). What could be a reason of that?
Thanks in advance
You need to configure your app.yaml file to open ports 8080 and 8000. You need to do this in addition to opening the port in your Dockerfile with EXPOSE. The documentation for how to setup your app.yaml file is located here, and the example from the docs is copied below:
Add the following to your app.yaml:
network:
instance_tag: TAG_NAME
name: NETWORK_NAME
subnetwork_name: SUBNETWORK_NAME
forwarded_ports:
- PORT
- HOST_PORT:CONTAINER_PORT
- PORT/tcp
- HOST_PORT:CONTAINER_PORT/udp
Run supervisord with -n argument.
This will run supervisor in foreground.
Works fine for me in app engine flexible environment.
Thanks
Following the instruction in https://www.dartlang.org/server/google-cloud-platform/app-engine/run.html
doesn't work anymore.
During the docker build phase it can't find pubspec.yaml ( Using regular expression with wildcard * ).
I'm using boot2docker and docker 1.5 and the google/dart-runtime image.
Any solution to solve this problem in the deploy of a Dart application in Google Cloud?
INFO 2015-03-08 14:41:12,215 containers.py:280] Step onbuild-0 : ADD pubspec.* /app/
ERROR 2015-03-08 14:41:12,244 containers.py:283] pubspec.*: no such file or directory
INFO 2015-03-08 14:41:12,244 containers.py:292] --------------------------------------------------------
ERROR 2015-03-08 14:41:12,244 instance.py:280] Docker build aborted: pubspec.*: no such file or directory
Updating docker client to latest version done the work:
boot2docker stop
boot2docker download
boot2docker start