Sails: Using NODE_ENV=production not working, while NODE_ENV=prod works fine - sails.js

I have config/env/production.js with production config.
When I try to start the server using PM2, it does not work. The server does not start and the process times out.
NODE_ENV=production pm2 start app.js
On renaming config/env/production.js to config/env/prod.js and using
NODE_ENV=prod pm2 start app.js
It works fine
This seems to be related to permission issues. I also tried it using 'sudo' but it did not help.
Does anyone have any idea about this?

Try to start the server using:
pm2 start app.js -- --prod

Related

WebStorm - run default configuration after starting the `Mongod` tool?

Currently I have a tool setup that will launch Mongod, following the advice of this post.
However, the issue is that when I have my configuration setup to run this Mongod tool before launching, it won't run my node script since there's no "successful completion" by Mongod.
Is there any way around this? In other words, can I have mongod start alongside my configuration but not block my script from running until it "completes"?

strapi start command not working

I want to start strapi cms in the browser but Tells me :
Make sure your MongoDB database is running
In the event MongoDB is running
How can I solve this problem?
Mongod & mongo is running
I had the same problem and I had to update mongo to 3.6, stop the mongod service using
$ sudo service mongod stop
and run mongod in a terminal and leave it open.
$ mongod
The next time it seemed to recognise the mongo service started by the command
$ sudo service mongod start
Go to your project file.
go to the config/environments/development folder and click on database.json. for username and password you leave it empty. and host you put 127.0.0.1 port: 27017 as in the picture
if you have finished the modifications you open two terminal:
on the first you start mongoDB by doing:
mongod
and once mongoDB has started you start on the other console strapi by making:
strapi start or npm start
Try removing the new plugins (if any) that you have installed.
I have faced this issue 2 times
Once I installed strapi command plugin
Another time I installed seo plugin.
I do no the root cause. But removing those packages and re-installed worked.

Using supervisor to run a flask app

I am deploying my Flask application on WebFaction. I am using flask-socketio which has lead me to deploying it with a Custom Websocket App (listening on port). Flask-socketio's instructs me to deploy my app by starting the serving with the call socketio.run(app, port= < port_listening_on >) in my main python script. I have installed eventlet on the server so socketio.run should run the app on the eventlet web server.
I can call python < app >.py and all works great – server runs, can view it at the domain, sockets working, etc. My problems start when I attempt to turn this into a long running process. I've been advised to use supervisor which I have installed and configured on my webapp following these instructions: https://community.webfaction.com/questions/18483/how-do-i-install-and-use-supervisord-to-control-long-running-processes
The problem is once I actually add the command for supervisor to run my app it errors with:
Exited too quickly
My log states the above error as well as:
(exit status 1; not expected)
In my supervisor config file I currently have the following program config:
[program:<prog_name>]
command=/usr/bin/python2.7 /home/<user>/webapps/<app_name>/<app>.py
autostart=true
autorestart=true
I have tried a removing and adding settings but it all leads to the same FATAL error.
So this is what part of my supervisor config looks like, I'm using gunicorn to run my flask app.
Also, I'm logging errors to a file from the supervisor config, so if you do that, it might help you see why it's not starting correctly.
[program:gunicorn]
command=/juzten/venv/bin/gunicorn run:app --preload -p rocket.pid -b 0.0.0.0:5000 --access-logfile "-"
directory=/juzten/app-folder-name
user=juzten
autostart=true
autorestart=unexpected
stdout_logfile=/juzten/gunicorn.log
stderr_logfile=/juzten/gunicorn.log

Can't run Mongo DB deamon in docker container

I'm running docker container in OSX using boot2docker. It is a latest Ubuntu image with mongo installed using official way from package mongodb-org.
I can perfectly run mongod from command line, but can't run it as a service.
When I'm trying to do sudo service mongod start it returns
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mongod start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mongod
I have tried to do start mongod which doesn't have any output. I have tried everything I found in Google, but no luck.
Meanwhile, I have tried to install MySQL using apt-get and I can perfectly run it as a service.
Also I have tried to install Mongo from Ubuntu's mongodb package which is a older version. Also no problem to run it as a service.
I suspect that there is something wrong with /etc/init.d/mongod script, but don't know exactly what.
Apprieciate any help.
The init-related commands on the Docker Ubuntu image are dummied out / not working because Upstart (/sbin/init) is not the first process started on the machine.
In general, any service which initializes using Upstart will not run properly in a Docker container unless you start the container with /sbin/init (you probably have to be using the ubuntu-upstart image, and make a bunch of tweaks to it too.)
If you really needed to do it this way, write a traditional init script for mongo and insert it using update-rc.d. Then, starting it with /sbin/service should work.
Why not just have the Dockerimage run mongod instead of init/shell/etc? "One process per container", right?
Use a Dockerfile to create your image, and set the CMD to:
CMD ["/usr/bin/mongod", "-f", "/etc/mongod.conf"]

Fabric and init

I am using fabric to restart tomcat and even though it says tomcat restarted successfully it does not. So, as per the FAQ, I set pty=False and tried again. But, now, I get this error:
sudo: /etc/init.d/tomcat restart
out: sudo: sorry, you must have a tty to run sudo
Any ideas around this problem?
To anyone reading this, this is not a problem with fabric but with the way sudo accounts have been set up. This property in /etc/sudoers file controls this;
Defaults requiretty