ninenines / cowboy

Small, fast, modern HTTP server for Erlang/OTP.
https://ninenines.eu
ISC License
7.29k stars 1.17k forks source link

deploy and hot upgrade #595

Closed ZhenguoYang closed 11 years ago

ZhenguoYang commented 11 years ago

It is not an issue.

As a rookie, If I have a web server developed on cowboy to deploy, how to do that?

My steps are:

  1. ssh to the remote server
  2. set up erlang environment
  3. copy beam files
  4. run erl -pa ebin deps/*/ebin -s web_server

However, I found the server will stop after a while.

And then, I found -detached can let the server run all the time.

My question is, How to deploy and hot upgrade (mantaince) a cowboy based http server remotely? Any sample?

Thanks in advance

dvv commented 11 years ago

Your session running erlang dies when ssh connection is closed. You should consider using tmux or screen to spawn long-living non-detached processes.

essen commented 11 years ago

what no

Look up releases. Almost all examples use them now, and the getting started chapter of the guide also shows them (look at the version that's on github, not on the website).

ZhenguoYang commented 11 years ago

@essen

I can find the getting started chapter in https://github.com/extend/cowboy/blob/master/guide/getting_started.md

what are the releases you mentioned?

Thanks in advance.

ZhenguoYang commented 11 years ago

@essen

I just saw it. In examples folder, you replaced rebar with relx.

ZhenguoYang commented 11 years ago

Hi @dvv @essen

If ssh connection effects session running erlang, there will be the same result for the release built by relx.

Btw, how to upgrade a go production server? I can't find related document on relx.

Thanks in advance.

essen commented 11 years ago

No releases can run in the background just fine.

Zhenguo Yang notifications@github.com wrote:

Hi @dvv @essen

If ssh connection effects session running erlang, there will be the same result for the release built by relx.

Btw, how to upgrade a go production server? I can't find related document on relx.

Thanks in advance.

— Reply to this email directly or view it on GitHub.

ZhenguoYang commented 11 years ago

Hi @essen,

Thanks. What my imagination is that:

  1. one command to start the release in background, such as: app start;
  2. one command to stop the release, such as: app stop;

Can we do that? Any suggestion?

Thanks in advance.

nevar commented 11 years ago

Hi @ZhenguoYang.

When you create release with relx it add scripts for start, stop, attach and etc. In release directory exists bin/ that you can use for start and stop release:

cd github/cowboy/examples/hello_world 
make
cd _rel
bin/hello_world_example start
<exists http://localhost:8080>
bin/hello_world_example stop
<don't exists http://localhost:8080>
ZhenguoYang commented 11 years ago

Hi @nevar ,

Cool, thanks a lot.

One more question.

If I used mnesia in my application, I need to figure out the db path when starting the server. e.g.

!/bin/sh

erl -pa ebin deps/*/ebin -mnesia dir '"db"'

How to handle it in relx?

Thanks in advance.

nevar commented 11 years ago

You have choise:

  1. Use start script and pass to it additional param for start erlang. bash bin/hello_world_example start -mnesia dir '"db"'
  2. Create vm.arg and sys.config for configure erlang and it application. If you're interested I can answer in more detail via email.
ZhenguoYang commented 11 years ago

Hi @nevar,

Thanks a lot.

Yes, I am interested in it.

Thanks in advance.

shailen1 commented 9 years ago

I'm also interested in using vm.arg and sys.config to configure mnesia for use in an app. Could you let me know the steps please ? (I think I need to have [{mnesia, [{dir, "/home/x/data/"}]}]. in my rel/sys.config; what do I need to have in vm.arg?) Thanks in advance

essen commented 9 years ago

Shouldn't need anything in vm.args.

Please don't ask questions on old tickets.

shailen1 commented 9 years ago

OK thanks, sorry about the question on a closed ticket, got googled here and didn't want to opena new one ...