Node Express JS - 需要为每次更新代码重新启动服务器应用程序

时间:2015-10-17 22:33:37

标签: mysql node.js windows express server

使用NodeJS命令行工具,我需要在更新源代码时通过以下命令重启服务器package name.zerosum; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.RadioButton; import android.widget.Spinner; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import java.util.ArrayList; public class NewGameActivity extends AppCompatActivity { public Spinner players, bestOf; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_new_game); players = (Spinner) findViewById(R.id.players); Integer[] items1 = new Integer[]{2, 3, 4, 5, 6, 7, 8, 9, 10}; ArrayAdapter<Integer> adapter1 = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, items1); players.setAdapter(adapter1); bestOf = (Spinner) findViewById(R.id.bestOf); Integer[] items2 = new Integer[]{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}; ArrayAdapter<Integer> adapter2 = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, items2); bestOf.setAdapter(adapter2); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_new_game, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } public void sendMessageStart(View view) { final RadioButton sign3 = (RadioButton) findViewById(R.id.radio3); final RadioButton sign5 = (RadioButton) findViewById(R.id.radio5); Button start = (Button) findViewById(R.id.startButton); start.setOnClickListener(new View.OnClickListener() { //int playerNum = Integer.valueOf(players.getSelectedItem().toString()); //int games = Integer.valueOf(bestOf.getSelectedItem().toString()); @Override public void onClick(View v) { ArrayList<Integer> players = new ArrayList<>(); Bundle bundle = new Bundle(); bundle.putInt("newPlayerNum", 1); bundle.putInt("numOfPlayers", 2); bundle.putInt("games", 1); bundle.putIntegerArrayList("players", players); if (sign3.isChecked()) { Intent intentBundle = new Intent(NewGameActivity.this, ThreeSignGameActivity.class); intentBundle.putExtras(bundle); startActivity(intentBundle); } else if (sign5.isChecked()) { Intent intentBundle = new Intent(NewGameActivity.this, FiveSignGameActivity.class); intentBundle.putExtras(bundle); startActivity(intentBundle); } } }); } } (在Windows上)。有什么命令可以阻止吗?例如更新源代码时自动重启服务器?没有结束,每次都重启正在运行的服务器。谢谢。

1 个答案:

答案 0 :(得分:1)

Nodemon监控您的应用程序,并在更新代码后重新启动Node服务器。您还可以运行特定命令:

https://github.com/remy/nodemon